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
a6088608
Verified
Commit
a6088608
authored
4 years ago
by
Alberto Miranda
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for chnk_ralign()
parent
f5a8ae18
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
+56
-0
56 additions, 0 deletions
tests/unit/test_util_numeric.cpp
with
56 additions
and
0 deletions
tests/unit/test_util_numeric.cpp
+
56
−
0
View file @
a6088608
...
...
@@ -70,3 +70,59 @@ SCENARIO(" offsets can be left-aligned to block size boundaries ",
}
}
}
SCENARIO
(
" offsets can be right-aligned to block size boundaries "
,
"[utils][numeric][chnk_ralign]"
)
{
using
namespace
gkfs
::
util
;
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 0 "
)
{
const
uint64_t
offset
=
0
;
CAPTURE
(
offset
,
block_size
);
THEN
(
" the right-aligned offset is block_size "
)
{
const
uint64_t
aligned_offset
=
chnk_ralign
(
offset
,
block_size
);
const
uint64_t
expected_offset
=
block_size
;
REQUIRE
(
aligned_offset
==
expected_offset
);
}
}
WHEN
(
" offset is smaller than 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 right-aligned offset is 0 "
)
{
const
uint64_t
aligned_offset
=
chnk_ralign
(
offset
,
block_size
);
const
uint64_t
expected_offset
=
block_size
;
REQUIRE
(
aligned_offset
==
expected_offset
);
}
}
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 right-aligned offset is the right boundary of the "
"containing block "
)
{
const
uint64_t
aligned_offset
=
chnk_ralign
(
offset
,
block_size
);
const
uint64_t
expected_offset
=
static_cast
<
uint64_t
>
(
offset
/
block_size
+
1
)
*
block_size
;
REQUIRE
(
aligned_offset
==
expected_offset
);
}
}
}
}
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