Ejemplo n.º 1
0
void test_filter_file1() {
  subst_list_type * subst_list = subst_list_alloc( NULL );
  test_work_area_type * work_area = test_work_area_alloc("subst_list/filter1");
  {
    FILE * stream = util_fopen("template" , "w");
    fprintf(stream , "<KEY1>\n<KEY2>\n<KEY3>\n<KEY4>\n");
    fclose(stream);
  }
  subst_list_append_copy( subst_list , "<KEY1>" , "Value1" , NULL);
  subst_list_append_copy( subst_list , "<KEY2>" , "Value2" , NULL);
  subst_list_append_copy( subst_list , "<KEY3>" , "Value3" , NULL);
  subst_list_append_copy( subst_list , "<KEY4>" , "Value4" , NULL);

  subst_list_filter_file( subst_list , "template" , "target");

  {
    FILE * stream = util_fopen("target" , "r");
    char s1[128],s2[128],s3[128],s4[128];

    test_assert_int_equal( 4 , fscanf( stream , "%s %s %s %s" , s1,s2,s3,s4));
    fclose(stream);

    test_assert_string_equal( s1 , "Value1");
    test_assert_string_equal( s2 , "Value2");
    test_assert_string_equal( s3 , "Value3");
    test_assert_string_equal( s4 , "Value4");
  }
  test_work_area_free( work_area );
  subst_list_free( subst_list );
}
Ejemplo n.º 2
0
void config_content_free( config_content_type * content ) {
  vector_free( content->nodes );
  vector_free( content->path_elm_stack );
  vector_free( content->path_elm_storage );
  hash_free( content->items );
  config_error_free( content->parse_errors );
  subst_list_free( content->define_list );
  util_safe_free( content->config_file );
  util_safe_free( content->abs_path );
  set_free( content->parsed_files );
  if (content->invoke_path != NULL)
    config_root_path_free( content->invoke_path );

  free( content );
}
Ejemplo n.º 3
0
void test_filter_file2() {
  subst_list_type * subst_list = subst_list_alloc( NULL );
  test_work_area_type * work_area = test_work_area_alloc("subst_list/filter2");
  {
    FILE * stream = util_fopen("template" , "w");
    fprintf(stream , "MAGIC_PRINT  magic-list.txt  <ERTCASE>  __MAGIC__");
    fclose(stream);
  }

  subst_list_append_copy( subst_list , "<QC_PATH>" , "QC" , NULL);
  subst_list_append_copy( subst_list , "__MAGIC__" , "MagicAllTheWayToWorkFlow" , NULL);
  subst_list_append_copy( subst_list , "<CASE>" , "SUPERcase" , NULL);
  subst_list_append_copy( subst_list , "<ERTCASE>" , "default" , NULL);
  subst_list_filter_file( subst_list , "template" , "target");

  {
    char * target_string = util_fread_alloc_file_content( "target" , NULL );
    test_assert_string_equal( target_string , "MAGIC_PRINT  magic-list.txt  default  MagicAllTheWayToWorkFlow");
    free( target_string );
  }
  test_work_area_free( work_area );
  subst_list_free( subst_list );
}
Ejemplo n.º 4
0
Archivo: gen_kw.c Proyecto: blattms/ert
void gen_kw_free(gen_kw_type *gen_kw) {
  util_safe_free( gen_kw->data );
  subst_list_free( gen_kw->subst_list );
  free(gen_kw);
}
Ejemplo n.º 5
0
void test_create() {
  subst_list_type * subst_list = subst_list_alloc( NULL );
  test_assert_true( subst_list_is_instance( subst_list ) );
  subst_list_free( subst_list );
}