Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
5eee032d
Commit
5eee032d
authored
7 years ago
by
Peter W. Draper
Browse files
Options
Downloads
Patches
Plain Diff
Sort out issues with trailing spaces in section names and update the test
parent
9dd8f360
No related branches found
No related tags found
1 merge request
!564
Yaml arrays
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/parser.c
+3
-2
3 additions, 2 deletions
src/parser.c
tests/testParser.c
+18
-0
18 additions, 0 deletions
tests/testParser.c
tests/testParserInput.yaml
+3
-3
3 additions, 3 deletions
tests/testParserInput.yaml
with
24 additions
and
5 deletions
src/parser.c
+
3
−
2
View file @
5eee032d
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
tests/testParser.c
+
18
−
0
View file @
5eee032d
...
...
@@ -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
;
}
This diff is collapsed.
Click to expand it.
tests/testParserInput.yaml
+
3
−
3
View file @
5eee032d
...
...
@@ -9,7 +9,7 @@ Scheduler:
kernel
:
4
Simulation
:
no_of_time_steps
:
10
no_of_time_steps
:
10
max_h
:
1.1255
start_time
:
1.23456789
...
...
@@ -17,6 +17,6 @@ IO:
#Input file
ic_file
:
ic_file.ini
#
Box:
#
sides: [2, 3, 4]
Box
:
sides
:
[
2
,
3
,
4
]
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment