Skip to content
Snippets Groups Projects
Commit 0119a458 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Added a test of the reading of optional parameters.

parent d64d1877
No related branches found
No related tags found
1 merge request!175Optional parameters
...@@ -50,14 +50,17 @@ int main(int argc, char *argv[]) { ...@@ -50,14 +50,17 @@ int main(int argc, char *argv[]) {
parser_get_param_double(&param_file, "Simulation:start_time"); parser_get_param_double(&param_file, "Simulation:start_time");
const int kernel = parser_get_param_int(&param_file, "kernel"); const int kernel = parser_get_param_int(&param_file, "kernel");
const int optional = parser_get_opt_param_int(&param_file, "optional", 1);
char ic_file[PARSER_MAX_LINE_SIZE]; char ic_file[PARSER_MAX_LINE_SIZE];
parser_get_param_string(&param_file, "IO:ic_file", ic_file); parser_get_param_string(&param_file, "IO:ic_file", ic_file);
/* Print the variables to check their values are correct. */ /* Print the variables to check their values are correct. */
printf( printf(
"no_of_threads: %d, no_of_time_steps: %d, max_h: %f, start_time: %lf, " "no_of_threads: %d, no_of_time_steps: %d, max_h: %f, start_time: %lf, "
"ic_file: %s, kernel: %d\n", "ic_file: %s, kernel: %d optional: %d\n",
no_of_threads, no_of_time_steps, max_h, start_time, ic_file, kernel); no_of_threads, no_of_time_steps, max_h, start_time, ic_file, kernel,
optional);
assert(no_of_threads == 16); assert(no_of_threads == 16);
assert(no_of_time_steps == 10); assert(no_of_time_steps == 10);
...@@ -65,6 +68,7 @@ int main(int argc, char *argv[]) { ...@@ -65,6 +68,7 @@ int main(int argc, char *argv[]) {
assert(fabs(start_time - 1.23456789) < 0.00001); assert(fabs(start_time - 1.23456789) < 0.00001);
assert(strcmp(ic_file, "ic_file.ini") == 0); /*strcmp returns 0 if correct.*/ assert(strcmp(ic_file, "ic_file.ini") == 0); /*strcmp returns 0 if correct.*/
assert(kernel == 4); assert(kernel == 4);
assert(optional == 1);
return 0; return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment