Commit 5eee032d authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Sort out issues with trailing spaces in section names and update the test

parent 9dd8f360
......@@ -350,8 +350,9 @@ static void parse_value(char *line, struct swift_params *params) {
/* Take second token as the parameter value. */
token = trim_both(strtok(NULL, "#\n"));
/* If second token is NULL then the line must be a section heading. */
if (token == NULL) {
/* If second token is NULL or empty then the line must be a section
* heading. */
if (token == NULL || strlen(token) == 0) {
strcpy(tmpSectionName, tmpStr);
strcat(tmpSectionName, PARSER_VALUE_STRING);
......
......@@ -55,12 +55,20 @@ int main(int argc, char *argv[]) {
char ic_file[PARSER_MAX_LINE_SIZE];
parser_get_param_string(&param_file, "IO:ic_file", ic_file);
float sides[3];
parser_get_param_float_array(&param_file, "Box:sides", 1, 3, sides);
float optsides[5] = {1.f, 2.f, 3.f, 4.f, 5.f};
int haveopt = parser_get_param_float_array(&param_file, "Box:moresides",
0, 3, optsides);
/* Print the variables to check their values are correct. */
printf(
"no_of_threads: %d, no_of_time_steps: %d, max_h: %f, start_time: %lf, "
"ic_file: %s, kernel: %d optional: %d\n",
no_of_threads, no_of_time_steps, max_h, start_time, ic_file, kernel,
optional);
printf("sides of box: %f %f %f\n", sides[0], sides[1], sides[2]);
assert(no_of_threads == 16);
assert(no_of_time_steps == 10);
......@@ -69,6 +77,16 @@ int main(int argc, char *argv[]) {
assert(strcmp(ic_file, "ic_file.ini") == 0); /*strcmp returns 0 if correct.*/
assert(kernel == 4);
assert(optional == 1);
assert(sides[0] == 2);
assert(sides[1] == 3);
assert(sides[2] == 4);
assert(haveopt == 0);
assert(optsides[0] == 1);
assert(optsides[1] == 2);
assert(optsides[2] == 3);
assert(optsides[3] == 4);
assert(optsides[4] == 5);
return 0;
}
......@@ -17,6 +17,6 @@ IO:
#Input file
ic_file: ic_file.ini
#Box:
# sides: [2, 3, 4]
Box:
sides: [2, 3, 4]
...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment