test_a_declared_macro_wins_over_the_header¶
Tests › tests/test_preprocessor.py
What this test is for
Why it exists
Doxygen's behaviour on a duplicated PREDEFINED name is not something to rely on, so the collision is resolved where the rule can be stated: the owner typed one of these by hand and the other was read out of a file.
Given
root = tmp_path / "repo"root.mkdir()(root / "cfg.h").write_text("#define WIDTH 8\n#define ONLY_IN_HEADER 1\n", encoding="utf-8")
When
config = resolve_preprocessor( root, {SECTION_PREPROCESSOR: {"predefined": ["WIDTH=16"], "config_header": "cfg.h"}}, )
Then
- ✓ config.macros contains '"WIDTH=16"'
- ✓ config.macros does not contain '"WIDTH=8"'
- ✓ config.macros contains '"ONLY_IN_HEADER=1"'
- ✓ config.source equals SOURCE_BOTH
tests/test_preprocessor.py:607 · its file's page
What it checks (4)
assert '"WIDTH=16"' in config.macrosobservesresolve_preprocessorviaconfigassert '"WIDTH=8"' not in config.macros, "the header overrode a hand-written declaration"observesresolve_preprocessorviaconfigassert '"ONLY_IN_HEADER=1"' in config.macros, "the header's other macros were dropped"observesresolve_preprocessorviaconfigassert config.source == SOURCE_BOTHobservesresolve_preprocessorviaconfig
Where the product reaches it
No product flow reaches this code: no product entry point's flow calls any of the functions this test calls.
Call flow
What it reaches
Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.
Also reaches 2 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-CONFIG-004 measured
- REQ-DDB-PIPE-014 measured