Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify that tests correctly handle rounding on 4GiB boundaries #21

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pkg/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ func BytesToGbRoundDown(bytes int64) int64 {
}

func BytesToGbRoundUp(bytes int64) int64 {
re := bytes / (1024 * 1024 * 1024)
if (bytes % (1024 * 1024 * 1024)) != 0 {
// TEST: verify that rounding to 4GiB works correctly
re := bytes / (1024 * 1024 * 1024 * 4)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re is now nr. of 4 GiB chunks in bytes. When you return re below, you should return 4 * re to return nr. of GiB chunks and not 4GiB chunks.

This took me some time :-D

if (bytes % (1024 * 1024 * 1024 * 4)) != 0 {
re++
}
return re
return 4 * re
}

func GbToBytes(Gb int64) int64 {
Expand Down