Skip to content

Fix sparse file test offset/length#263

Merged
folbricht merged 2 commits intofolbricht:masterfrom
bearrito:bug/sparse-file-test
Mar 10, 2024
Merged

Fix sparse file test offset/length#263
folbricht merged 2 commits intofolbricht:masterfrom
bearrito:bug/sparse-file-test

Conversation

@bearrito
Copy link
Copy Markdown
Contributor

@bearrito bearrito commented Mar 9, 2024

Fixes #262

Comment thread sparse-file_test.go Outdated
// Read a few random ranges and compare to the expected blob content
for i := 0; i < 1000; i++ {
length := rand.Intn(int(index.Index.ChunkSizeMax))
offset := rand.Intn(int(index.Length()) - length)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Shouldn't this be?

offset := rand.Intn(int(index.Length()) - length - 1)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Three hard things in computer science: off-by-one errors and naming things.

I'll fix it up.

@folbricht folbricht merged commit 7502cbb into folbricht:master Mar 10, 2024
JeremieA pushed a commit to InSimo/desync that referenced this pull request Apr 10, 2026
* Fix sparse file test offset/length

* Fix off-by-one error

---------

Co-authored-by: bstrausser <bstrausser@locusrobotics.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failing sparsefile tests

2 participants