54 const wxString original = wxS(
"Net-(Q6-Pad2)" );
55 const wxString renamed = wxS(
"Net-(Q6-B)" );
59 const unsigned netCount = board->GetNetInfo().GetNetCount();
60 std::vector<std::tuple<BOARD_CONNECTED_ITEM*, NETINFO_ITEM*, int, wxString>> before;
61 std::set<KICAD_T> renamedTypes;
65 before.emplace_back( item, item->GetNet(), item->GetNetCode(), item->GetNetname() );
67 if( item->GetNet() == net )
68 renamedTypes.insert( item->Type() );
76 { { original, renamed }, { wxS(
"N999999999" ), wxS(
"Net-(Absent-Pad1)" ) } },
reporter ) );
77 BOOST_CHECK( board->FindNet( original ) ==
nullptr );
78 BOOST_CHECK( board->FindNet( renamed ) == net );
79 BOOST_CHECK( board->FindNet( code ) == net );
81 BOOST_CHECK( board->FindNet( wxS(
"Net-(Absent-Pad1)" ) ) ==
nullptr );
83 for(
const auto& [item, oldNet, oldCode, oldName] : before )
85 BOOST_CHECK( item->GetNet() == oldNet );
94 FOOTPRINT* held = board->FindFootprintByReference( wxS(
"Q3" ) );
97 empty->SetValue( wxString() );
98 empty->GetField( wxS(
"Description" ) )->SetText( wxString() );
103 for(
const wxString& ref : { wxS(
"Q6" ), wxS(
"Q3" ) } )
106 nlohmann::ordered_map<wxString, wxString> fields = { { wxS(
"Reference" ), ref },
107 { wxS(
"Value" ), wxS(
"FromSchematic" ) },
108 { wxS(
"Maker" ), wxS(
"Acme" ) },
109 { wxS(
"Description" ), wxS(
"Resistor" ) } };
111 if( ref == wxS(
"Q6" ) )
112 fields[wxS(
"Serial" )] = wxString();
115 netlist.AddComponent( component );
120 maker->
SetName( wxS(
"Maker" ) );
121 maker->
SetText( wxS(
"Board" ) );
128 BOOST_CHECK(
empty->HasField( wxS(
"Serial" ) ) );
136 FOOTPRINT* lowered = board->FindFootprintByReference( wxS(
"Q6" ) );
137 FOOTPRINT* named = board->FindFootprintByReference( wxS(
"Q3" ) );
145 for(
const wxString& ref : { wxS(
"Q6" ), wxS(
"Q3" ) } )
156 const wxString first = wxS(
"Net-(Q6-Pad2)" );
157 const wxString second = wxS(
"Net-(Q6-Pad3)" );
161 std::vector<std::tuple<NETINFO_ITEM*, int, wxString>> before;
164 before.emplace_back( net, net->GetNetCode(), net->GetNetname() );
166 const std::vector<std::map<wxString, wxString>> invalid = {
167 { { first, wxS(
"Net-(Q6-B)" ) }, { second, wxS(
"GND" ) } },
168 { { first, wxS(
"Net-(Q6-B)" ) }, { second, wxS(
"Net-(Q6-B)" ) } },
169 { { first, wxS(
"Net-(Q6-B)" ) }, { second, wxString() } },
170 { { wxString(), wxS(
"Net-(Q6-B)" ) } }
173 for(
const auto& names : invalid )
177 BOOST_CHECK( !
reporter.GetMessages().IsEmpty() );
180 for(
const auto& [net, code,
name] : before )
184 BOOST_CHECK( board->FindNet(
name ) == net );
185 BOOST_CHECK( board->FindNet( code ) == net );
192 const wxString first = wxS(
"Net-(Q6-Pad2)" );
193 const wxString second = wxS(
"Net-(Q6-Pad3)" );
198 const int secondCode = secondNet->
GetNetCode();
201 BOOST_CHECK( board->FindNet( first ) == secondNet );
202 BOOST_CHECK( board->FindNet( second ) == firstNet );
203 BOOST_CHECK( board->FindNet( firstCode ) == firstNet );
204 BOOST_CHECK( board->FindNet( secondCode ) == secondNet );
209 const wxString original = wxS(
"/ATN_IN" );
210 const wxString renamed = wxS(
"/RENAMED_ATN_IN" );
213 auto settings = board->GetDesignSettings().m_NetSettings;
215 const auto assignedClass = settings->GetEffectiveNetClass( original );
216 BOOST_REQUIRE_EQUAL( assignedClass->GetName(), wxString(
"HV" ) );
217 BOOST_REQUIRE( settings->GetEffectiveNetClass( renamed ) == settings->GetDefaultNetclass() );
219 std::vector<std::pair<wxString, wxString>> expectedPatterns;
221 for(
const auto& [matcher,
name] : settings->GetNetclassPatternAssignments() )
222 expectedPatterns.emplace_back( matcher->GetPattern() == original ? renamed : matcher->GetPattern(),
name );
227 BOOST_CHECK( settings->GetEffectiveNetClass( renamed ) == assignedClass );
228 BOOST_CHECK( settings->GetEffectiveNetClass( original ) == settings->GetDefaultNetclass() );
229 std::vector<std::pair<wxString, wxString>> actualPatterns;
231 for(
const auto& [matcher,
name] : settings->GetNetclassPatternAssignments() )
232 actualPatterns.emplace_back( matcher->GetPattern(),
name );
234 BOOST_CHECK( actualPatterns == expectedPatterns );
235 settings->ClearAllCaches();
236 BOOST_CHECK( settings->GetEffectiveNetClass( renamed ) == assignedClass );
241 const wxString original = wxS(
"/ATN_IN" );
242 const wxString renamed = wxS(
"/RECOLOURED_ATN_IN" );
243 auto settings = board->GetDesignSettings().m_NetSettings;
246 settings->SetNetColorAssignment( original, colour );
251 const auto& colours = settings->GetNetColorAssignments();
253 BOOST_REQUIRE_EQUAL( colours.count( renamed ), 1 );
254 BOOST_CHECK( colours.at( renamed ) == colour );
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
Store all of the related component information found in a netlist.
void SetFields(nlohmann::ordered_map< wxString, wxString > aFields)
virtual void SetText(const wxString &aText)
A color representation with 4 components: red, green, blue, alpha.
A logical library item identifier and consists of various portions much like a URI.
A collection of nets and the parameters used to route or test these nets.
Handle the data for a net.
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
void SetName(const wxString &aName)
A wrapper for reporting to a wxString object.
static bool empty(const wxTextEntryBase *aCtrl)
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.
int ReconcileImportedReferences(BOARD &aBoard, NETLIST &aNetlist)
Give an imported board footprint the reference its schematic symbol uses.
int FillImportedFootprintFields(BOARD &aBoard, NETLIST &aNetlist)
Copy what an imported board footprint lacks from the schematic symbol it is linked to.
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()
@ USER
The field ID hasn't been set yet; field is invalid.
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)