Skip to content

use 64bit sizes so tests pass on 32bit platforms #4

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions index.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace Hyper {
namespace Core {
namespace FlatTree {
using size_t = uint64_t;
size_t T0 = 0;
size_t T1 = 1;
size_t T2 = 2;
Expand Down
28 changes: 14 additions & 14 deletions test/index.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ int main() {
// this deviates from the original implementation.
//
ASSERT("children 0", FlatTree::children(0).empty())
ASSERT("children 1", FlatTree::children(1) == std::vector<size_t> { 0, 2 })
ASSERT("children 3", FlatTree::children(3) == std::vector<size_t> { 1, 5 })
ASSERT("children 9", FlatTree::children(9) == std::vector<size_t> { 8, 10 })
ASSERT("children 1", FlatTree::children(1) == std::vector<FlatTree::size_t> { 0, 2 })
ASSERT("children 3", FlatTree::children(3) == std::vector<FlatTree::size_t> { 1, 5 })
ASSERT("children 9", FlatTree::children(9) == std::vector<FlatTree::size_t> { 8, 10 })

ASSERT("leftChild 0", FlatTree::leftChild(0) == -1)
ASSERT("leftChild 1", FlatTree::leftChild(1) == 0)
Expand All @@ -57,11 +57,11 @@ int main() {
ASSERT("sibling 5", FlatTree::sibling(5) == 1)

ASSERT("fullRoots 0", FlatTree::fullRoots(0).empty())
ASSERT("fullRoots 2", FlatTree::fullRoots(2) == std::vector<size_t> { 0 })
ASSERT("fullRoots 8", FlatTree::fullRoots(8) == std::vector<size_t> { 3 })
ASSERT("fullRoots 20", FlatTree::fullRoots(20) == std::vector<size_t> { 7, 17 })
ASSERT("fullRoots 18", FlatTree::fullRoots(18) == std::vector<size_t> { 7, 16 })
ASSERT("fullRoots 16", FlatTree::fullRoots(16) == std::vector<size_t> { 7 })
ASSERT("fullRoots 2", FlatTree::fullRoots(2) == std::vector<FlatTree::size_t> { 0 })
ASSERT("fullRoots 8", FlatTree::fullRoots(8) == std::vector<FlatTree::size_t> { 3 })
ASSERT("fullRoots 20", FlatTree::fullRoots(20) == std::vector<FlatTree::size_t> { 7, 17 })
ASSERT("fullRoots 18", FlatTree::fullRoots(18) == std::vector<FlatTree::size_t> { 7, 16 })
ASSERT("fullRoots 16", FlatTree::fullRoots(16) == std::vector<FlatTree::size_t> { 7 })

ASSERT("depth 0", FlatTree::depth(0) == 0)
ASSERT("depth 1", FlatTree::depth(1) == 1)
Expand All @@ -75,11 +75,11 @@ int main() {
ASSERT("offset 3", FlatTree::offset(3) == 0)
ASSERT("offset 4", FlatTree::offset(4) == 2)

ASSERT("spans 0", FlatTree::spans(0) == std::vector<size_t> { 0, 0 })
ASSERT("spans 1", FlatTree::spans(1) == std::vector<size_t> { 0, 2 })
ASSERT("spans 3", FlatTree::spans(3) == std::vector<size_t> { 0, 6 })
ASSERT("spans 23", FlatTree::spans(23) == std::vector<size_t> { 16, 30 })
ASSERT("spans 27", FlatTree::spans(27) == std::vector<size_t> { 24, 30 })
ASSERT("spans 0", FlatTree::spans(0) == std::vector<FlatTree::size_t> { 0, 0 })
ASSERT("spans 1", FlatTree::spans(1) == std::vector<FlatTree::size_t> { 0, 2 })
ASSERT("spans 3", FlatTree::spans(3) == std::vector<FlatTree::size_t> { 0, 6 })
ASSERT("spans 23", FlatTree::spans(23) == std::vector<FlatTree::size_t> { 16, 30 })
ASSERT("spans 27", FlatTree::spans(27) == std::vector<FlatTree::size_t> { 24, 30 })

ASSERT("leftSpan 0", FlatTree::leftSpan(0) == 0)
ASSERT("leftSpan 1", FlatTree::leftSpan(1) == 0)
Expand All @@ -103,7 +103,7 @@ int main() {
ASSERT("parent > int32", FlatTree::parent(10000000000) == 10000000001)

ASSERT("twopow 34", FlatTree::twoPow(34) == 17179869184)
ASSERT("twopow 63", FlatTree::twoPow(63) == 9223372036854775808)
ASSERT("twopow 63", FlatTree::twoPow(63) == 9223372036854775808ULL)

{
size_t child = 0;
Expand Down