catchorg / catchorg/Catch2

STATIC_REQUIRE/STATIC_CHECK and code coverage

Open
#2,350 2 comments 4 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
21.5k
Forks
3.5k
Avg merge
3d 16h
Merged PRs (30d)
2

Description

When using STATIC_REQUIRE/STATIC_CHECK to test constexpr functions, gcov ignores these checks as they are not executed at runtime, reporting a lower code coverage than I actually have.

CATCH_CONFIG_RUNTIME_STATIC_REQUIRE solves that, but then I lose the advantages of STATIC_REQUIRE.

It would be great if there was a define that would make STATIC_REQUIRE assert *both* at compile time and runtime, or custom macros doing that (not sure what good names would be...), like

#define STATIC_REQUIRE2(expr) { STATIC_REQUIRE(expr); REQUIRE(expr); } // naive version; also note I didn't solve the naming problem

Contributor guide

Open the contributing guide

Research direction

Start by locating the definitions and uses of STATIC_REQUIRE, STATIC_CHECK, and CATCH_CONFIG_RUNTIME_STATIC_REQUIRE in Catch2. Compare their compile-time and runtime behavior, then determine how a combined check should preserve both while allowing gcov to see runtime execution. Done means the proposed behavior is specified and covered by tests for constexpr checks and runtime coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.