82 m_schematic->ConnectionGraph()->RunERC();
96 BOOST_CHECK_MESSAGE( multiUnitErrors > 0,
97 "Expected ERC to detect shared pin on different nets.\n"
101 bool foundDifferentUnitNetError =
false;
103 for(
int i = 0; i < errors.
GetCount(); ++i )
105 std::shared_ptr<RC_ITEM> item = errors.
GetItem( i );
109 foundDifferentUnitNetError =
true;
114 BOOST_CHECK_MESSAGE( foundDifferentUnitNetError,
115 "Expected ERCE_DIFFERENT_UNIT_NET error for shared pin 2.\n"
134 for(
bool backend : {
false,
true } )
140 std::unique_ptr<SCHEMATIC> schematic;
142 schematic->RebuildConnectivity();
144 std::vector<SCH_SYMBOL*> units;
148 auto* symbol =
static_cast<SCH_SYMBOL*
>( item );
150 if( symbol->GetRef( &
path ) !=
"VD1" )
153 units.push_back( symbol );
156 BOOST_REQUIRE_EQUAL( units.size(), 4u );
157 EXPORTER exporter( schematic.get(),
nullptr );
158 EXPORTER::CONNECTIVITY_SCOPE connectivity( exporter );
159 size_t sharedPins = 0;
161 for(
const PIN_INFO&
pin : exporter.CreatePinList( units.front(),
path ) )
171 std::vector<PIN_INFO> nativePins;
172 exporter.findAllUnitsOfSymbol( units.front(),
path, nativePins );
173 std::erase_if( nativePins, [](
const PIN_INFO&
pin ) {
return pin.num !=
"2"; } );
174 BOOST_REQUIRE_EQUAL( nativePins.size(), 4u );
176 for(
bool userFirst : {
false,
true } )
178 auto pins = nativePins;
179 std::stable_partition( pins.begin(), pins.end(), [&](
const PIN_INFO&
pin )
181 return ( pin.netName ==
"GND" ) == userFirst;
183 BOOST_REQUIRE_EQUAL( pins.front().netName ==
"GND", userFirst );
184 exporter.eraseDuplicatePins( pins );
185 std::erase_if( pins, [](
const PIN_INFO&
pin ) {
return pin.num.empty(); } );
186 BOOST_REQUIRE_EQUAL( pins.size(), 1u );
200 std::unique_ptr<SCHEMATIC> schematic;
202 schematic->RebuildConnectivity();
204 const auto run = [&]()
207 std::vector<std::string> markers;
214 auto* marker =
static_cast<SCH_MARKER*
>( item );
217 const auto ercItem = std::static_pointer_cast<ERC_ITEM>( marker->GetRCItem() );
218 BOOST_CHECK( ercItem->GetSpecificSheetPath().LastScreen() == screen );
220 + marker->GetRCItem()->GetErrorMessage(
true ).ToStdString() );
226 std::sort( markers.begin(), markers.end() );
229 const auto legacy = run();
232 schematic->RebuildConnectivity();
233 schematic->ConnectionGraph()->Reset();
234 const auto captured = run();
235 BOOST_TEST( captured == legacy, boost::test_tools::per_element() );
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
static ERC_EXCLUSION FromMarker(const SCH_MARKER &aMarker)
wxString GetTextReport()
Returns the ERC report in "text" (human readable) format in the C-locale.
Container for ERC settings.
std::map< int, SEVERITY > m_ERCSeverities
Runs the electrical rules checks and adds a SCH_MARKER for each violation.
int TestMultUnitPinConflicts()
Checks if shared pins on multi-unit symbols have been connected to different nets.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
void findAllUnitsOfSymbol(SCH_SYMBOL *aSchSymbol, const SCH_SHEET_PATH &aSheetPath, std::vector< PIN_INFO > &aPins)
Find all units for symbols with multiple symbols per package.
void eraseDuplicatePins(std::vector< PIN_INFO > &pins)
Erase duplicate pins.
std::vector< PIN_INFO > CreatePinList(SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH &aSheetPath)
Find a symbol from the DrawList and builds its pin list.
Generate the KiCad netlist format supported by Pcbnew.
NETLIST_EXPORTER_KICAD(SCHEMATIC *aSchematic, KIWAY *aKiway)
Base class for any item which can be embedded within the SCHEMATIC container class,...
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
void DeleteAllMarkers(enum MARKER_BASE::MARKER_T aMarkerType, bool aIncludeExclusions)
Delete all electronic rules check markers of aMarkerType from all the screens in the list.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
RAII class that sets an value at construction and resets it to the original value at destruction.
An implementation of the RC_ITEM_LIST interface which uses the global SHEETLIST to fulfill the contra...
int GetCount(int aSeverity=-1) const override
void SetSeverities(int aSeverities) override
std::shared_ptr< RC_ITEM > GetItem(int aIndex) const override
Retrieve a RC_ITEM by index.
@ ERCE_DIFFERENT_UNIT_NET
Shared pin in a multi-unit symbol is connected to more than one net.
@ ERCE_LIB_SYMBOL_MISMATCH
Symbol doesn't match copy in library.
@ ERCE_LIB_SYMBOL_ISSUES
Symbol not found in active libraries.
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
std::vector< FAB_LAYER_COLOR > dummy
ERC_SHARED_PIN_TEST_FIXTURE()=default
std::unique_ptr< SCHEMATIC > m_schematic
SETTINGS_MANAGER m_settingsManager
BOOST_AUTO_TEST_CASE(Issue1768_NetlistPreferUserNet)
BOOST_FIXTURE_TEST_CASE(Issue1768_SharedPinDifferentNets, ERC_SHARED_PIN_TEST_FIXTURE)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_TEST(netlist.find("R_G1 ARM_OUT1 DIE_B R='0.001 / ((SW_STATE)") !=std::string::npos)
BOOST_TEST_CONTEXT("Test Clearance")
BOOST_CHECK_EQUAL(result, "25.4")