KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_issue9673_bus_alias_highlighting.cpp
Go to the documentation of this file.
1
/*
2
* This program source code file is part of KiCad, a free EDA CAD application.
3
*
4
* Copyright The KiCad Developers, see AUTHORS.TXT for contributors.
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 3
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, you may find one here:
18
* https://www.gnu.org/licenses/gpl-3.0.en.html
19
* or you may search the http://www.gnu.org website for the version 32 license,
20
* or you may write to the Free Software Foundation, Inc.,
21
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22
*/
23
29
30
#include <
qa_utils/wx_utils/unit_test_utils.h
>
31
#include <
schematic_utils/schematic_file_util.h
>
32
33
#include <
connection_graph.h
>
34
#include <
schematic.h
>
35
#include <
sch_sheet.h
>
36
#include <
sch_screen.h
>
37
#include <
settings/settings_manager.h
>
38
#include <
locale_io.h
>
39
40
struct
ISSUE9673_FIXTURE
41
{
42
ISSUE9673_FIXTURE
()
43
{ }
44
45
SETTINGS_MANAGER
m_settingsManager
;
46
std::unique_ptr<SCHEMATIC>
m_schematic
;
47
};
48
49
50
// Equivalents must carry the sheet-path prefix the highlight/navigator code passes in.
51
BOOST_FIXTURE_TEST_CASE
( Issue9673BusAliasEquivalence,
ISSUE9673_FIXTURE
)
52
{
53
LOCALE_IO
dummy
;
54
55
KI_TEST::LoadSchematic
( m_settingsManager,
"issue9673/issue9673"
, m_schematic );
56
57
CONNECTION_GRAPH
* graph = m_schematic->ConnectionGraph();
58
59
std::vector<wxString> equivAlias = graph->
GetEquivalentBusNames
( wxT(
"/{MIXED_BUS}"
) );
60
BOOST_REQUIRE_EQUAL( equivAlias.size(), 1u );
61
BOOST_CHECK_EQUAL
( equivAlias[0], wxT(
"/{FOO BAR HAM EGGS}"
) );
62
63
std::vector<wxString> equivExpanded = graph->
GetEquivalentBusNames
( wxT(
"/{FOO BAR HAM EGGS}"
) );
64
BOOST_REQUIRE_EQUAL( equivExpanded.size(), 1u );
65
BOOST_CHECK_EQUAL
( equivExpanded[0], wxT(
"/{MIXED_BUS}"
) );
66
67
// A plain net and an undefined alias have no equivalents.
68
BOOST_CHECK( graph->
GetEquivalentBusNames
( wxT(
"/FOO"
) ).
empty
() );
69
BOOST_CHECK( graph->
GetEquivalentBusNames
( wxT(
"/{UNKNOWN_BUS}"
) ).
empty
() );
70
}
71
72
73
// Each form's equivalent must resolve to the other form's subgraphs; that cross-form reach is
74
// what the highlight and navigator rely on.
75
BOOST_FIXTURE_TEST_CASE
( Issue9673EquivalentResolvesToSubgraphs,
ISSUE9673_FIXTURE
)
76
{
77
LOCALE_IO
dummy
;
78
79
KI_TEST::LoadSchematic
( m_settingsManager,
"issue9673/issue9673"
, m_schematic );
80
81
CONNECTION_GRAPH
* graph = m_schematic->ConnectionGraph();
82
83
// Both written forms exist as separate subgraphs.
84
BOOST_REQUIRE
( !graph->
GetAllSubgraphs
( wxT(
"/{MIXED_BUS}"
) ).
empty
() );
85
BOOST_REQUIRE
( !graph->
GetAllSubgraphs
( wxT(
"/{FOO BAR HAM EGGS}"
) ).
empty
() );
86
87
// Before the fix the equivalent list was empty for path-qualified names, so the cross-form
88
// highlight missed.
89
std::vector<wxString> equivAlias = graph->
GetEquivalentBusNames
( wxT(
"/{MIXED_BUS}"
) );
90
BOOST_REQUIRE_EQUAL( equivAlias.size(), 1u );
91
BOOST_CHECK( !graph->
GetAllSubgraphs
( equivAlias[0] ).empty() );
92
93
std::vector<wxString> equivExpanded = graph->
GetEquivalentBusNames
( wxT(
"/{FOO BAR HAM EGGS}"
) );
94
BOOST_REQUIRE_EQUAL( equivExpanded.size(), 1u );
95
BOOST_CHECK( !graph->
GetAllSubgraphs
( equivExpanded[0] ).empty() );
96
}
CONNECTION_GRAPH
Calculate the connectivity of a schematic and generates netlists.
Definition
connection_graph.h:375
CONNECTION_GRAPH::GetAllSubgraphs
const std::vector< CONNECTION_SUBGRAPH * > & GetAllSubgraphs(const wxString &aNetName) const
Definition
connection_graph.cpp:4955
CONNECTION_GRAPH::GetEquivalentBusNames
std::vector< wxString > GetEquivalentBusNames(const wxString &aBusName) const
Map a bus group name between its alias and expanded forms ({MIXED_BUS} <-> {FOO BAR HAM EGGS}...
Definition
connection_graph.cpp:4968
LOCALE_IO
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition
locale_io.h:37
SETTINGS_MANAGER
Definition
settings_manager.h:49
connection_graph.h
empty
static bool empty(const wxTextEntryBase *aCtrl)
Definition
dialog_sim_command.cpp:37
locale_io.h
KI_TEST::LoadSchematic
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
Definition
schematic_file_util.cpp:184
sch_screen.h
sch_sheet.h
schematic.h
schematic_file_util.h
settings_manager.h
dummy
std::vector< FAB_LAYER_COLOR > dummy
Definition
stackup_predefined_prms.cpp:93
ISSUE9673_FIXTURE
Definition
test_issue9673_bus_alias_highlighting.cpp:41
ISSUE9673_FIXTURE::ISSUE9673_FIXTURE
ISSUE9673_FIXTURE()
Definition
test_issue9673_bus_alias_highlighting.cpp:42
ISSUE9673_FIXTURE::m_settingsManager
SETTINGS_MANAGER m_settingsManager
Definition
test_issue9673_bus_alias_highlighting.cpp:45
ISSUE9673_FIXTURE::m_schematic
std::unique_ptr< SCHEMATIC > m_schematic
Definition
test_issue9673_bus_alias_highlighting.cpp:46
BOOST_REQUIRE
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_FIXTURE_TEST_CASE
BOOST_FIXTURE_TEST_CASE(Issue9673BusAliasEquivalence, ISSUE9673_FIXTURE)
Definition
test_issue9673_bus_alias_highlighting.cpp:51
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
unit_test_utils.h
src
qa
tests
eeschema
test_issue9673_bus_alias_highlighting.cpp
Generated on Tue Jul 7 2026 00:07:27 for KiCad PCB EDA Suite by
1.13.2