Re: [PATCH] Add tests for Bitmapset
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Greg Burd <greg@burd.me>
Cc: Robert Haas <robertmhaas@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Nathan Bossart <nathandbossart@gmail.com>, Masahiko Sawada <sawada.mshk@gmail.com>
Date: 2025-09-16T06:04:03Z
Lists: pgsql-hackers
On Mon, Sep 15, 2025 at 03:56:30PM -0400, Greg Burd wrote:
> Reworked as indicated, thanks for pointing out the anti-pattern I'd
> missed.
Hmm. Should we try to get something closer in shape to what we do for
the SLRU tests, with one SQL function mapping to each C function we
are testing? This counts for bms_is_member(), bms_num_members(), add,
del, mul, hash and make_singleton.
+test_bms_del_member_negative(PG_FUNCTION_ARGS)
+{
+ /* This should throw an error for negative member */
+ bms_del_member(NULL, -20);
+ PG_RETURN_VOID();
For example, this case could use a Bitmapset and a number (or an array
of numbers for repeated operations), with NULL being one option for
the input Bitmapset. This makes the tests a bit more representative
of what they do at SQL level, hence there would be no need to
double-check a given line where a failure happens. The Bitmapset
could then be passed around as bytea blobs using \gset, for example.
This should not be a problem as long as they are palloc'd in the
TopMemoryContext. The SQL output for true/false/NULL/non-NULL
generated as output of the test could then be used instead of the
EXPECT_*() macros reported then in the elogs.
Perhaps my view of things is too cute and artistic, but when these
test suites grow over time and differ across branches, having to dig
into a specific line of a specific branch to get what a problem is
about is more error-prone. Particularly annoying when calling one
single function that does a lot of various actions, like the proposed
test_bitmapset().
Side note: `git diff --check` is reporting a bunch of indents with
spaces around the EXPECT macros.
--
Michael
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Minor fixes for test_bitmapset.c
- 5142f0093e64 19 (unreleased) landed
-
test_bitmapset: Improve random function
- 9d46b86529e8 19 (unreleased) landed
-
Add mem_exceeded_count column to pg_stat_replication_slots.
- d3b6183dd988 19 (unreleased) landed
-
Tidy-up unneeded NULL parameter checks from SQL function
- a69b55cd4727 19 (unreleased) landed
-
Remove check for NULL in STRICT function
- 381f5cffae00 19 (unreleased) landed
-
Fixes for comments in test_bitmapset
- a1b064e4b226 19 (unreleased) landed
-
Minor fixups of test_bitmapset.c
- 3a6615806859 19 (unreleased) landed
-
test_bitmapset: Simplify code of the module
- 9952f6c05a40 19 (unreleased) landed
-
test_bitmapset: Expand more the test coverage
- 5668fff3c512 19 (unreleased) landed
-
Fix compiler warnings in test_bitmapset
- f83fe65f3fc1 19 (unreleased) landed
-
Add a test module for Bitmapset
- 00c3d87a5cab 19 (unreleased) landed