Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Lukas Weber
load_leveller
Commits
87480d42
Commit
87480d42
authored
Jun 07, 2019
by
Lukas Weber
Browse files
using a unit test to find a bug in the duration parser B)
parent
ade03b37
Changes
4
Hide whitespace changes
Inline
Side-by-side
meson.build
View file @
87480d42
...
...
@@ -19,3 +19,4 @@ should_install = not meson.is_subproject()
loadleveller_deps
=
[
fmt_dep
,
yamlcpp_dep
,
mpi_dep
,
hdf5_lib
]
subdir
(
'src'
)
subdir
(
'test'
)
src/runner.cpp
View file @
87480d42
...
...
@@ -26,7 +26,7 @@ enum {
// parses the duration '[[hours:]minutes:]seconds' into seconds
// replace as soon as there is an alternative
static
double
parse_duration
(
std
::
string
str
)
{
static
int
parse_duration
(
const
std
::
string
&
str
)
{
size_t
idx
;
try
{
...
...
@@ -46,7 +46,7 @@ static double parse_duration(std::string str) {
throw
std
::
runtime_error
{
"minutes"
};
}
return
24
*
60
*
i1
+
60
*
i2
+
i3
;
return
60
*
60
*
i1
+
60
*
i2
+
i3
;
}
else
{
throw
std
::
runtime_error
{
"hours"
};
}
...
...
test/duration_parser.cpp
0 → 100644
View file @
87480d42
#include
"runner.cpp"
int
main
()
{
using
namespace
loadl
;
if
(
parse_duration
(
"20"
)
!=
20
)
{
return
1
;
}
if
(
parse_duration
(
"10:03"
)
!=
10
*
60
+
3
)
{
return
2
;
}
if
(
parse_duration
(
"24:06:10"
)
!=
60
*
60
*
24
+
60
*
6
+
10
)
{
return
3
;
}
return
0
;
}
test/meson.build
0 → 100644
View file @
87480d42
t1
=
executable
(
'test_duration_parser'
,
'duration_parser.cpp'
,
dependencies
:
loadleveller_dep
,
include_directories
:
include_directories
(
'../src'
)
)
test
(
'test duration parser'
,
t1
)
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment