mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Fix yet more portability bugs in integerset and its tests.
There were more large constants that needed UINT64CONST. And one variable was declared as "int", when it needed to be uint64. These bugs were only visible on 32-bit systems; clearly I should've tested on one, given that this code does a lot of work with 64-bit integers. Also, in the test "huge distances" test, the code created some values with random distances between them, but the test logic didn't take into account the possibility that the random distance was exactly 1. That never actually happens with the seed we're using, but let's be tidy.
This commit is contained in:
@ -590,12 +590,14 @@ test_huge_distances(void)
|
||||
for (int i = 0; i < num_values; i++)
|
||||
{
|
||||
uint64 x = values[i];
|
||||
bool expected;
|
||||
bool result;
|
||||
|
||||
if (x > 0)
|
||||
{
|
||||
expected = (values[i - 1] == x - 1);
|
||||
result = intset_is_member(intset, x - 1);
|
||||
if (result != false)
|
||||
if (result != expected)
|
||||
elog(ERROR, "intset_is_member failed for " UINT64_FORMAT, x - 1);
|
||||
}
|
||||
|
||||
@ -603,8 +605,9 @@ test_huge_distances(void)
|
||||
if (result != true)
|
||||
elog(ERROR, "intset_is_member failed for " UINT64_FORMAT, x);
|
||||
|
||||
expected = (i != num_values - 1) ? (values[i + 1] == x + 1) : false;
|
||||
result = intset_is_member(intset, x + 1);
|
||||
if (result != false)
|
||||
if (result != expected)
|
||||
elog(ERROR, "intset_is_member failed for " UINT64_FORMAT, x + 1);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user