MONC
test_configurationfileparser.F90
Go to the documentation of this file.
1 ! Unit tests for the options database functionality
3  use collections_mod, only : map_type, c_get
9  use fruit, only : assert_equals, assert_true, assert_false
10 
11  implicit none
12 
13 contains
14 
15  ! Test some modules are read correctly
17  type(map_type) :: options_database
18  class(*), pointer :: raw_data
19 
20  call parse_configuration_file(options_database, "user_config")
21 
22  raw_data=>c_get(options_database, "viscosity_enabled")
23  call assert_false(conv_to_logical(raw_data, .false.), "Test viscosity is not enable")
24 
25  raw_data=>c_get(options_database, "rhobous")
26  call assert_equals(1.0, conv_to_real(raw_data, .false.), "Test setup configuration values")
27 
28  raw_data=>c_get(options_database, "passive_q")
29  call assert_false(conv_to_logical(raw_data, .false.), "Test logical value is false when missing")
30 
31  raw_data=>c_get(options_database, "number_q_fields")
32  call assert_equals(5, conv_to_integer(raw_data, .false.), "Test integer values read")
33 
34  raw_data=>c_get(options_database, "checkpoint_enable_write")
35  call assert_true(conv_to_logical(raw_data, .false.), "Test result when entry is not defined in the user file but in the global file")
36 
37  end subroutine test_parse_configuration_file
38 
40 
42  use fruit, only : init_fruit, run_test_case, fruit_summary
44  implicit none
45 
46  call init_fruit
47  call run_test_case(test_parse_configuration_file, "Test values from user file")
48  call fruit_summary
test_configuration_file_parser_driver
program test_configuration_file_parser_driver
Definition: test_configurationfileparser.F90:41
conversions_mod
Conversion between common inbuilt FORTRAN data types.
Definition: conversions.F90:5
collections_mod::map_type
Map data structure that holds string (length 20 maximum) key value pairs.
Definition: collections.F90:86
test_configuration_file_parser_mod
Definition: test_configurationfileparser.F90:2
conversions_mod::conv_is_logical
Determines whether a data item can be represented as a logical or not.
Definition: conversions.F90:100
optionsdatabase_mod::options_get_array_size
integer function, public options_get_array_size(options_database, key)
Gets the size of the array held in the options database corresponding to a specific key.
Definition: optionsdatabase.F90:342
configuration_file_parser_mod::parse_configuration_file
subroutine, public parse_configuration_file(options_database, user_configuration_file)
Parses a specific configuration and adds the contents into the options database.
Definition: configurationfileparser.F90:27
conversions_mod::conv_to_integer
Converts data types to integers.
Definition: conversions.F90:49
collections_mod
Collection data structures.
Definition: collections.F90:7
conversions_mod::conv_to_logical
Converts data types to logical.
Definition: conversions.F90:71
test_configuration_file_parser_mod::test_parse_configuration_file
subroutine test_parse_configuration_file
Definition: test_configurationfileparser.F90:17
optionsdatabase_mod::options_add
Generic add interface for adding different types of data to the databases.
Definition: optionsdatabase.F90:28
optionsdatabase_mod::options_get_string
character(len=string_length) function, public options_get_string(options_database, key, index)
Retrieves a string value from the database that matches the provided key.
Definition: optionsdatabase.F90:280
configuration_file_parser_mod
Parses a configuration file and loads the contents into the options database which can then be intero...
Definition: configurationfileparser.F90:3
optionsdatabase_mod::options_has_key
logical function, public options_has_key(options_database, key)
Determines whether a specific key is in the database.
Definition: optionsdatabase.F90:76
conversions_mod::conv_to_string
Converts data types to strings.
Definition: conversions.F90:38
conversions_mod::conv_is_real
Determines whether a data item can be represented as a real or not.
Definition: conversions.F90:91
conversions_mod::conv_is_integer
Determines whether a data item can be represented as an integer or not.
Definition: conversions.F90:81
conversions_mod::conv_to_real
Converts data types to real.
Definition: conversions.F90:60
optionsdatabase_mod
Manages the options database. Contains administration functions and deduce runtime options from the c...
Definition: optionsdatabase.F90:7
optionsdatabase_mod::options_remove_key
subroutine, public options_remove_key(options_database, key)
Removes a specific key from the options database, if it is an array then the entire array is removed.
Definition: optionsdatabase.F90:384