Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gekkofs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
hpc
gekkofs
Commits
874cb1a8
Verified
Commit
874cb1a8
authored
4 years ago
by
Alberto Miranda
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for chnk_rpad()
parent
56947cea
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/unit/test_util_numeric.cpp
+84
-0
84 additions, 0 deletions
tests/unit/test_util_numeric.cpp
with
84 additions
and
0 deletions
tests/unit/test_util_numeric.cpp
+
84
−
0
View file @
874cb1a8
...
...
@@ -284,3 +284,87 @@ SCENARIO(" overrun distance can be computed correctly ",
}
}
}
SCENARIO
(
" underrun distance can be computed correctly "
,
"[utils][numeric][chnk_rpad]"
)
{
GIVEN
(
" a block size "
)
{
const
std
::
size_t
block_size
=
GENERATE
(
filter
(
[](
uint64_t
bs
)
{
return
is_power_of_2
(
bs
);
},
range
(
0
,
100000
)));
WHEN
(
" offset is smaller than block_size "
)
{
AND_WHEN
(
" offset equals 0 "
)
{
const
uint64_t
offset
=
0
;
CAPTURE
(
offset
,
block_size
);
THEN
(
" the computed underrun distance equals block_size "
)
{
const
uint64_t
underrun
=
chnk_rpad
(
offset
,
block_size
);
const
uint64_t
expected_underrun
=
block_size
;
REQUIRE
(
underrun
==
expected_underrun
);
}
}
AND_WHEN
(
" 0 < offset < block_size "
)
{
const
uint64_t
offset
=
GENERATE_COPY
(
take
(
test_reps
,
random
(
std
::
size_t
{
0
},
block_size
-
1
)));
CAPTURE
(
offset
,
block_size
);
THEN
(
" the computed underrun distance equals offset "
)
{
const
uint64_t
underrun
=
chnk_rpad
(
offset
,
block_size
);
const
uint64_t
expected_underrun
=
block_size
-
offset
;
REQUIRE
(
underrun
==
expected_underrun
);
}
}
AND_WHEN
(
" offset equals block_size - 1 "
)
{
const
uint64_t
offset
=
block_size
-
1
;
CAPTURE
(
offset
,
block_size
);
THEN
(
" the computed underrun distance equals block_size - 1 "
)
{
const
uint64_t
underrun
=
chnk_rpad
(
offset
,
block_size
);
const
uint64_t
expected_underrun
=
block_size
-
offset
;
REQUIRE
(
underrun
==
expected_underrun
);
}
}
}
WHEN
(
" offset equals block_size "
)
{
const
uint64_t
offset
=
block_size
;
CAPTURE
(
offset
,
block_size
);
THEN
(
" the computed underrun distance equals block_size "
)
{
const
uint64_t
underrun
=
chnk_rpad
(
offset
,
block_size
);
const
uint64_t
expected_underrun
=
block_size
;
REQUIRE
(
underrun
==
expected_underrun
);
}
}
WHEN
(
" offset is larger than block_size "
)
{
const
uint64_t
offset
=
GENERATE_COPY
(
take
(
test_reps
,
random
(
block_size
,
block_size
*
31
)));
CAPTURE
(
offset
,
block_size
);
THEN
(
" the computed underrun distance equals the difference between "
"offset and its closest block's right boundary "
)
{
const
uint64_t
underrun
=
chnk_rpad
(
offset
,
block_size
);
const
uint64_t
expected_underrun
=
static_cast
<
uint64_t
>
(
offset
/
block_size
+
1
)
*
block_size
-
offset
;
REQUIRE
(
underrun
==
expected_underrun
);
}
}
}
}
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