Skip to content

Commit 4f7c3fa

Browse files
author
Christian Parpart
committed
[tests] Guard prefetch GUID optional access for clang-tidy
The block-prefetch GUID test dereferenced the TryParse result after a Catch2 REQUIRE, which clang-tidy's bugprone-unchecked-optional-access does not track as a guard (-warnings-as-errors). Add an explicit `if (has_value())` so the optional access is statically checked while keeping the REQUIRE as the failure signal. Signed-off-by: Christian Parpart <c.parpart@lastrada.net>
1 parent 50281ed commit 4f7c3fa

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/tests/SqlStatementPrefetchTests.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,8 @@ TEST_CASE_METHOD(SqlTestFixture, "Prefetch: GUID column round-trips", "[prefetch
514514
{
515515
auto const parsedUid = SqlGuid::TryParse(std::format("12345678-1234-1234-1234-{:012}", i));
516516
REQUIRE(parsedUid.has_value());
517-
(void) stmt.Execute(static_cast<std::int64_t>(i), *parsedUid);
517+
if (parsedUid.has_value()) // explicit guard so the optional access is statically checked
518+
(void) stmt.Execute(static_cast<std::int64_t>(i), *parsedUid);
518519
}
519520

520521
auto readGuids = [&](SqlStatement& source) {

0 commit comments

Comments
 (0)