forked from organicmaps/organicmaps
[coding_tests] [bit_streams] Fix a case of shift by 64 which doesn't always work correctly.
This commit is contained in:
parent
d3a15d8d15
commit
ab43d88914
1 changed files with 5 additions and 1 deletions
|
@ -27,6 +27,9 @@ UNIT_TEST(BitStream_ReadWrite)
|
|||
{
|
||||
uint32_t numBits = GetRand64() % 57;
|
||||
uint64_t num = GetRand64() & (uint64_t(-1) >> (64 - numBits));
|
||||
// Right bit shift by 64 doesn't always work correctly,
|
||||
// this is a workaround.
|
||||
if (numBits == 0) num = 0;
|
||||
nums.push_back(make_pair(num, numBits));
|
||||
}
|
||||
|
||||
|
@ -42,5 +45,6 @@ UNIT_TEST(BitStream_ReadWrite)
|
|||
{
|
||||
uint64_t num = bitsSource.Read(nums[i].second);
|
||||
TEST_EQUAL(num, nums[i].first, ());
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue