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
32
33#include <connection_graph.h>
34#include <schematic.h>
35#include <sch_sheet.h>
36#include <sch_screen.h>
38#include <locale_io.h>
39
41{
44
46 std::unique_ptr<SCHEMATIC> m_schematic;
47};
48
49
50// Equivalents must carry the sheet-path prefix the highlight/navigator code passes in.
51BOOST_FIXTURE_TEST_CASE( Issue9673BusAliasEquivalence, ISSUE9673_FIXTURE )
52{
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.
75BOOST_FIXTURE_TEST_CASE( Issue9673EquivalentResolvesToSubgraphs, ISSUE9673_FIXTURE )
76{
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}
Calculate the connectivity of a schematic and generates netlists.
const std::vector< CONNECTION_SUBGRAPH * > & GetAllSubgraphs(const wxString &aNetName) const
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}...
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition locale_io.h:37
static bool empty(const wxTextEntryBase *aCtrl)
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
std::vector< FAB_LAYER_COLOR > dummy
std::unique_ptr< SCHEMATIC > m_schematic
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_FIXTURE_TEST_CASE(Issue9673BusAliasEquivalence, ISSUE9673_FIXTURE)
BOOST_CHECK_EQUAL(result, "25.4")