KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_issue24044_expression_net_names.cpp File Reference

Go to the source code of this file.

Classes

struct  ISSUE_24044_FIXTURE
 

Functions

 BOOST_FIXTURE_TEST_CASE (Issue24044ExpressionNetNames, ISSUE_24044_FIXTURE)
 Test for issue #24044: Inconsistent internal evaluation of net names when using expressions.
 
 BOOST_FIXTURE_TEST_CASE (Issue24044PathFormEquivalence, ISSUE_24044_FIXTURE)
 Companion regression test that pins the contract SCH_LABEL_BASE::ResolveTextVar relies on.
 

Function Documentation

◆ BOOST_FIXTURE_TEST_CASE() [1/2]

BOOST_FIXTURE_TEST_CASE ( Issue24044ExpressionNetNames ,
ISSUE_24044_FIXTURE  )

Test for issue #24044: Inconsistent internal evaluation of net names when using expressions.

When a hierarchical sheet pin uses an expression that depends on the sheet instance (e.g. "@{(${#}-2)*2+1}" where ${#} is the page number), the net name resolved for the sheet pin on the parent sheet must match the name resolved for the matching hierarchical label inside the child sheet.

Schematic structure: Root sheet (page 1) with connector J1

  • Sheet "Channels 0-1" (page 2, channels.kicad_sch)
  • Sheet "Channels 2-3" (page 3, channels.kicad_sch) Child sheet channels.kicad_sch:
  • Hierarchical labels "Ch@{(${#}-2)*2+0}" and "Ch@{(${#}-2)*2+1}"
  • Resistors R1/R3 and R2/R4 driven by the labels

Expected resolved names (pin on parent must equal label inside child): Instance "Channels 0-1" (page 2): Ch0, Ch1 Instance "Channels 2-3" (page 3): Ch2, Ch3

The bug caused the parent-side sheet pin to resolve with a doubly-nested path that yielded an empty page number, producing bogus names (e.g. Ch-4/Ch-3) and breaking connectivity across the hierarchy.

Definition at line 68 of file test_issue24044_expression_net_names.cpp.

References actual, BOOST_CHECK_EQUAL(), BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), dummy, expected, SCH_SHEET::GetPins(), SCH_SHEET::GetScreen(), SCH_LABEL_BASE::GetShownText(), SCH_SCREEN::Items(), KI_TEST::LoadSchematic(), path, pin, and SCH_HIER_LABEL_T.

◆ BOOST_FIXTURE_TEST_CASE() [2/2]

BOOST_FIXTURE_TEST_CASE ( Issue24044PathFormEquivalence ,
ISSUE_24044_FIXTURE  )

Companion regression test that pins the contract SCH_LABEL_BASE::ResolveTextVar relies on.

Callers use one of two path forms when resolving a sheet pin's text:

  1. The child-sheet path (path.Last() is the sheet that owns the pin) — used by e.g. connection_graph.cpp driverName() and erc.cpp hier_label checks.
  2. The parent-screen path (path.Last() is the parent screen, child sheet not yet pushed) — used by e.g. sch_selection_tool.cpp pin-trick label generation.

Both forms must resolve to the same text for the same sheet instance. The bug fixed by issue #24044 broke form (1) by unconditionally pushing the owner sheet again, yielding a doubly-nested path whose page-number lookup failed.

Definition at line 198 of file test_issue24044_expression_net_names.cpp.

References BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), dummy, SCH_SHEET::GetPins(), KI_TEST::LoadSchematic(), path, pin, SCH_SHEET_PATH::pop_back(), and SCH_SHEET_PATH::size().