50 const wxString original = wxS(
"Net-(Q6-Pad2)" );
51 const wxString renamed = wxS(
"Net-(Q6-B)" );
55 const unsigned netCount = board->GetNetInfo().GetNetCount();
56 std::vector<std::tuple<BOARD_CONNECTED_ITEM*, NETINFO_ITEM*, int, wxString>> before;
57 std::set<KICAD_T> renamedTypes;
61 before.emplace_back( item, item->GetNet(), item->GetNetCode(), item->GetNetname() );
63 if( item->GetNet() == net )
64 renamedTypes.insert( item->Type() );
72 { { original, renamed }, { wxS(
"N999999999" ), wxS(
"Net-(Absent-Pad1)" ) } },
reporter ) );
73 BOOST_CHECK( board->FindNet( original ) ==
nullptr );
74 BOOST_CHECK( board->FindNet( renamed ) == net );
75 BOOST_CHECK( board->FindNet( code ) == net );
77 BOOST_CHECK( board->FindNet( wxS(
"Net-(Absent-Pad1)" ) ) ==
nullptr );
79 for(
const auto& [item, oldNet, oldCode, oldName] : before )
81 BOOST_CHECK( item->GetNet() == oldNet );
89 const wxString first = wxS(
"Net-(Q6-Pad2)" );
90 const wxString second = wxS(
"Net-(Q6-Pad3)" );
94 std::vector<std::tuple<NETINFO_ITEM*, int, wxString>> before;
97 before.emplace_back( net, net->GetNetCode(), net->GetNetname() );
99 const std::vector<std::map<wxString, wxString>> invalid = {
100 { { first, wxS(
"Net-(Q6-B)" ) }, { second, wxS(
"GND" ) } },
101 { { first, wxS(
"Net-(Q6-B)" ) }, { second, wxS(
"Net-(Q6-B)" ) } },
102 { { first, wxS(
"Net-(Q6-B)" ) }, { second, wxString() } },
103 { { wxString(), wxS(
"Net-(Q6-B)" ) } }
106 for(
const auto& names : invalid )
110 BOOST_CHECK( !
reporter.GetMessages().IsEmpty() );
113 for(
const auto& [net, code,
name] : before )
117 BOOST_CHECK( board->FindNet(
name ) == net );
118 BOOST_CHECK( board->FindNet( code ) == net );
125 const wxString first = wxS(
"Net-(Q6-Pad2)" );
126 const wxString second = wxS(
"Net-(Q6-Pad3)" );
131 const int secondCode = secondNet->
GetNetCode();
134 BOOST_CHECK( board->FindNet( first ) == secondNet );
135 BOOST_CHECK( board->FindNet( second ) == firstNet );
136 BOOST_CHECK( board->FindNet( firstCode ) == firstNet );
137 BOOST_CHECK( board->FindNet( secondCode ) == secondNet );
142 const wxString original = wxS(
"/ATN_IN" );
143 const wxString renamed = wxS(
"/RENAMED_ATN_IN" );
146 auto settings = board->GetDesignSettings().m_NetSettings;
148 const auto assignedClass = settings->GetEffectiveNetClass( original );
149 BOOST_REQUIRE_EQUAL( assignedClass->GetName(), wxString(
"HV" ) );
150 BOOST_REQUIRE( settings->GetEffectiveNetClass( renamed ) == settings->GetDefaultNetclass() );
152 std::vector<std::pair<wxString, wxString>> expectedPatterns;
154 for(
const auto& [matcher,
name] : settings->GetNetclassPatternAssignments() )
155 expectedPatterns.emplace_back( matcher->GetPattern() == original ? renamed : matcher->GetPattern(),
name );
160 BOOST_CHECK( settings->GetEffectiveNetClass( renamed ) == assignedClass );
161 BOOST_CHECK( settings->GetEffectiveNetClass( original ) == settings->GetDefaultNetclass() );
162 std::vector<std::pair<wxString, wxString>> actualPatterns;
164 for(
const auto& [matcher,
name] : settings->GetNetclassPatternAssignments() )
165 actualPatterns.emplace_back( matcher->GetPattern(),
name );
167 BOOST_CHECK( actualPatterns == expectedPatterns );
168 settings->ClearAllCaches();
169 BOOST_CHECK( settings->GetEffectiveNetClass( renamed ) == assignedClass );
174 const wxString original = wxS(
"/ATN_IN" );
175 const wxString renamed = wxS(
"/RECOLOURED_ATN_IN" );
176 auto settings = board->GetDesignSettings().m_NetSettings;
179 settings->SetNetColorAssignment( original, colour );
184 const auto& colours = settings->GetNetColorAssignments();
186 BOOST_REQUIRE_EQUAL( colours.count( renamed ), 1 );
187 BOOST_CHECK( colours.at( renamed ) == colour );
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
A color representation with 4 components: red, green, blue, alpha.
A collection of nets and the parameters used to route or test these nets.
Handle the data for a net.
A wrapper for reporting to a wxString object.
Abstract pattern-matching tool and implementations.
bool ApplyImportedNetNameMap(BOARD &aBoard, const std::map< wxString, wxString > &aNames, REPORTER &aReporter)
Apply caller-selected imported net names without changing net identity or connectivity.
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
SETTINGS_MANAGER settings
std::unique_ptr< BOARD > board
IMPORT_NET_NAMES_FIXTURE()
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(RenamePreservesConnectedItemsAndBothNetIndexes)
IbisParser parser & reporter
BOOST_CHECK_EQUAL(result, "25.4")
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)