70 SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
79 const std::set<wxString> originalNets = potential->
GetNets();
80 const std::size_t originalNetCnt = originalNets.size();
81 const std::size_t originalSymCnt = potential->
GetSymbols().size();
83 BOOST_REQUIRE_GT( originalNetCnt, 0u );
84 BOOST_REQUIRE_GT( originalSymCnt, 0u );
88 BOOST_REQUIRE_EQUAL( committed->
GetNets().size(), originalNetCnt );
89 BOOST_REQUIRE_EQUAL( committed->
GetSymbols().size(), originalSymCnt );
97 BOOST_REQUIRE_MESSAGE( refreshed,
98 "Committed chain disappeared across unconditional Recalculate" );
100 BOOST_CHECK_MESSAGE( !refreshed->
GetSymbols().empty(),
101 "Committed chain has empty m_symbols after unconditional Recalculate; "
102 "Reset() cleared the cache and RebuildNetChains() failed to refresh it" );
104 BOOST_CHECK_MESSAGE( !refreshed->
GetNets().empty(),
105 "Committed chain has empty m_nets after unconditional Recalculate" );
121 BOOST_CHECK( !twice->
GetNets().empty() );
170 for(
bool backend : {
false,
true } )
176 std::unique_ptr<SCHEMATIC> schematic;
179 schematic->RebuildConnectivity();
180 auto& chains = schematic->NetChains();
181 const auto sheets = schematic->BuildSheetListSortedByPageNumbers();
182 BOOST_REQUIRE_EQUAL( sheets.size(), 1u );
183 const auto&
path = sheets.front();
185 auto*
chain = chains.CreateNetChainFromPotential( chains.GetPotentialNetChains().front().get(),
188 const KIID originalA =
chain->GetTerminalPinA();
189 const KIID originalB =
chain->GetTerminalPinB();
190 auto* original =
dynamic_cast<SCH_PIN*
>( schematic->ResolveItem( originalA,
nullptr,
true ) );
192 const auto connection = original->GetConnectionName( &
path );
194 SCH_PIN* replacement =
nullptr;
200 const auto net =
pin->GetConnectionName( &
path );
202 if(
pin->m_Uuid != originalA &&
pin->m_Uuid != originalB
203 && net && *net == *connection )
215 const KIID replacementId = replacement->
m_Uuid;
217 const wxString replacementNumber = replacement->
GetNumber();
218 BOOST_CHECK( !chains.ReplaceNetChainTerminalPin( {
"TERM_OVERRIDE", 1, originalA, path.Path() } ) );
219 BOOST_REQUIRE( chains.ReplaceNetChainTerminalPin( {
"TERM_OVERRIDE", 1, replacementId, path.Path() } ) );
220 BOOST_CHECK(
chain->GetTerminalPinA() == originalA );
221 BOOST_CHECK(
chain->GetTerminalPinB() == replacementId );
222 BOOST_REQUIRE( chains.ReplaceNetChainTerminalPin( {
"TERM_OVERRIDE", 1, originalB, path.Path() } ) );
223 BOOST_REQUIRE( chains.ReplaceNetChainTerminalPin( {
"TERM_OVERRIDE", 0, replacementId, path.Path() } ) );
225 BOOST_CHECK(
chain->GetTerminalPath( 0 ) ==
path.Path() );
226 BOOST_CHECK( !chains.ReplaceNetChainTerminalPin( {
"TERM_OVERRIDE", 2, originalA, path.Path() } ) );
228 for(
int pass = 0; pass < 2; ++pass )
230 schematic->RebuildConnectivity();
231 BOOST_CHECK( chains.GetNetChainByName(
"TERM_OVERRIDE" ) ==
chain );
232 BOOST_CHECK(
chain->GetTerminalPinA() == replacementId );
233 BOOST_CHECK(
chain->GetTerminalPinB() == originalB );
234 BOOST_CHECK(
chain->GetTerminalPath( 0 ) ==
path.Path() );
240 auto library = replacementSymbol->GetLibSymbolRef()->Flatten();
241 replacementSymbol->SetLibSymbol(
library.release() );
242 schematic->RebuildConnectivity();
243 BOOST_CHECK(
chain->GetTerminalPinA() == replacementId );
244 BOOST_CHECK(
chain->GetTerminalPath( 0 ) ==
path.Path() );
248 replacementRef =
"R900";
250 schematic->RebuildConnectivity();
251 BOOST_CHECK( chains.GetNetChainByName(
"TERM_OVERRIDE" ) ==
chain );
252 BOOST_CHECK(
chain->GetTerminalPinA() == replacementId );
256 replacementRef =
"R901";
259 const wxString file = wxFileName::CreateTempFileName(
"netchain-terminal-" );
261 std::ifstream stream( file.ToStdString() );
265 reloaded->RebuildConnectivity();
266 auto* restored = reloaded->NetChains().GetNetChainByName(
"TERM_OVERRIDE" );
268 BOOST_CHECK( restored->GetTerminalPinA() == replacementId );
269 BOOST_CHECK( restored->GetTerminalPinB() == originalB );
273 wxRemoveFile( file );
276 path.LastScreen()->Remove( removedSymbol );
277 std::unique_ptr<SCH_SYMBOL> removed( removedSymbol );
279 schematic->RebuildConnectivity();
280 BOOST_CHECK(
chain->GetTerminalPinA() == replacementId );
281 BOOST_CHECK(
chain->GetTerminalPath( 0 ) ==
path.Path() );
282 BOOST_CHECK( !
chain->GetSymbols().contains( removed.get() ) );
283 BOOST_CHECK(
chain->GetNets().empty() );
BOOST_CHECK_EQUAL(result, "25.4")