62 const std::vector<std::pair<wxString, int>> cases = {
63 {
"ground_pin_test_error", 1 },
64 {
"ground_pin_test_mixed", 1 },
65 {
"ground_pin_test_ok", 0 },
66 {
"ground_pin_test_no_ground_net", 0 },
67 {
"ground_pin_test_earth", 0 }
70 for(
const auto& [fixture,
expected] : cases )
76 m_schematic->RebuildConnectivity();
77 m_schematic->ConnectionGraph()->Reset();
84 for(
int i = 0; i < errors.
GetCount(); ++i )
97 for(
bool backend : {
false,
true } )
101 std::vector<SCH_SHEET_PATH> paths;
105 if(
path.LastScreen()->GetFileName().EndsWith(
"ampli_ht.kicad_sch" ) )
106 paths.push_back(
path );
109 BOOST_REQUIRE_EQUAL( paths.size(), 2 );
118 auto* candidate =
static_cast<SCH_SYMBOL*
>( item );
139 if(
pin->GetNumber() == wxString(
"4" ) )
141 else if(
pin->GetNumber() == wxString(
"5" ) )
142 selected =
pin.get();
147 BOOST_REQUIRE_EQUAL( common->
GetUnit(), 0 );
148 BOOST_REQUIRE_EQUAL( selected->
GetUnit(), 2 );
151 libraryPin->SetName(
"GND" );
153 BOOST_REQUIRE_EQUAL( selected->
GetShownName(), wxString(
"GND" ) );
155 BOOST_REQUIRE_EQUAL( ground->
GetPins( &paths[0] ).size(), 1 );
156 BOOST_REQUIRE_EQUAL( supply->
GetPins( &paths[0] ).size(), 1 );
159 screen->
Update( symbol,
false );
160 screen->
Update( ground,
false );
161 screen->
Update( supply,
false );
162 m_schematic->RebuildConnectivity();
165 m_schematic->ConnectionGraph()->Reset();
168 m_schematic->SetCurrentSheet( paths[0] );
175 const auto* marker =
static_cast<SCH_MARKER*
>( item );
178 || marker->GetRCItem()->GetMainItemID() != selected->
m_Uuid )
181 const auto error = std::static_pointer_cast<ERC_ITEM>( marker->GetRCItem() );
182 BOOST_CHECK( error->GetSpecificSheetPath().PathRef() == paths[1].PathRef() );
183 BOOST_CHECK( marker->GetPosition() == selected->
GetPosition() );
217 m_schematic->ConnectionGraph()->RunERC();
226 BOOST_CHECK_MESSAGE( errors.
GetCount() == 1,
227 "Expected 1 ERCE_GROUND_PIN_NOT_GROUND error but got "
231 bool foundGroundPinError =
false;
232 for(
unsigned i = 0; i < errors.
GetCount(); i++ )
236 foundGroundPinError =
true;
241 BOOST_CHECK_MESSAGE( foundGroundPinError,
242 "Expected to find ERCE_GROUND_PIN_NOT_GROUND error\n"
268 m_schematic->ConnectionGraph()->RunERC();
278 int groundPinErrors = 0;
279 for(
unsigned i = 0; i < errors.
GetCount(); i++ )
287 BOOST_CHECK_MESSAGE( groundPinErrors == 0,
288 "Expected 0 ERCE_GROUND_PIN_NOT_GROUND errors but got "
289 << groundPinErrors <<
"\n" << reportWriter.
GetTextReport() );
316 m_schematic->ConnectionGraph()->RunERC();
326 int groundPinErrors = 0;
327 for(
unsigned i = 0; i < errors.
GetCount(); i++ )
335 BOOST_CHECK_MESSAGE( groundPinErrors == 1,
336 "Expected 1 ERCE_GROUND_PIN_NOT_GROUND error but got "
337 << groundPinErrors <<
"\n" << reportWriter.
GetTextReport() );
364 m_schematic->ConnectionGraph()->RunERC();
374 int groundPinErrors = 0;
375 for(
unsigned i = 0; i < errors.
GetCount(); i++ )
383 BOOST_CHECK_MESSAGE( groundPinErrors == 0,
384 "Expected 0 ERCE_GROUND_PIN_NOT_GROUND errors but got "
385 << groundPinErrors <<
"\n" << reportWriter.
GetTextReport() );
406 int groundPinErrors = 0;
410 m_schematic->ConnectionGraph()->RunERC();
417 for(
unsigned i = 0; i < errors.
GetCount(); i++ )
425 BOOST_CHECK_MESSAGE( groundPinErrors == 0,
426 "Expected 0 errors when test is disabled but got " << groundPinErrors );
430 m_schematic->ConnectionGraph()->RunERC();
438 for(
unsigned i = 0; i < errors.
GetCount(); i++ )
446 BOOST_CHECK_MESSAGE( groundPinErrors >= 1,
447 "Expected at least 1 error when test is enabled but got " << groundPinErrors );
471 m_schematic->ConnectionGraph()->RunERC();
479 bool foundGroundPinError =
false;
480 wxString errorMessage;
482 for(
unsigned i = 0; i < errors.
GetCount(); i++ )
486 foundGroundPinError =
true;
490 BOOST_CHECK_MESSAGE( errorMessage.Contains(
"Pin" ),
491 "Error message should contain 'Pin': " << errorMessage.ToStdString() );
493 BOOST_CHECK_MESSAGE( errorMessage.Contains(
"GND" ),
494 "Error message should contain 'GND': " << errorMessage.ToStdString() );
496 BOOST_CHECK_MESSAGE( errorMessage.Contains(
"not connected to ground net" ),
497 "Error message should contain expected text: " << errorMessage.ToStdString() );
500 std::shared_ptr<RC_ITEM> ercItem = errors.
GetItem( i );
501 BOOST_CHECK_MESSAGE( ercItem->GetMainItemID() !=
niluuid,
502 "ERC item should have a main item (the pin)" );
508 BOOST_CHECK_MESSAGE( foundGroundPinError,
509 "Should have found a ground pin error to test message content" );
531 m_schematic->ConnectionGraph()->RunERC();
540 int groundPinErrors = 0;
542 for(
unsigned i = 0; i < errors.
GetCount(); i++ )
550 BOOST_CHECK_MESSAGE( groundPinErrors == 0,
551 "Expected 0 ERCE_GROUND_PIN_NOT_GROUND errors (Earth is a valid ground net) but got "
552 << groundPinErrors <<
"\n" << reportWriter.
GetTextReport() );
565 std::vector<std::pair<wxString, int>> tests =
567 {
"ground_pin_test_error", 1 },
568 {
"ground_pin_test_ok", 0 },
569 {
"ground_pin_test_mixed", 1 },
570 {
"ground_pin_test_no_ground_net", 0 },
571 {
"ground_pin_test_earth", 0 }
574 for(
const std::pair<wxString, int>&
test : tests )
588 m_schematic->ConnectionGraph()->RunERC();
604 int groundPinErrors = 0;
605 for(
unsigned i = 0; i < errors.
GetCount(); i++ )
615 BOOST_CHECK_MESSAGE( groundPinErrors ==
test.second,
616 "Expected " <<
test.second <<
" ERCE_GROUND_PIN_NOT_GROUND errors in "
617 <<
test.first.ToStdString() <<
" but got " << groundPinErrors
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
EE_TYPE OfType(KICAD_T aType) const
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 TestPinToPin()
Checks the full netlist against the pin-to-pin connectivity requirements.
int TestSimilarLabels()
Checks for labels that differ only in capitalization.
int TestMultUnitPinConflicts()
Checks if shared pins on multi-unit symbols have been connected to different nets.
int TestNoConnectPins()
In KiCad 5 and earlier, you could connect stuff up to pins with NC electrical type.
int TestGroundPins()
Checks for ground-labeled pins not on a ground net while another pin is.
int TestMissingUnits()
Test for uninstantiated units of multi unit symbols.
int TestMultiunitFootprints()
Test if all units of each multiunit symbol have the same footprint assigned.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
virtual wxString GetErrorMessage(bool aTranslate) const
virtual const wxString & GetText() const override
Return the string associated with the text object.
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual void SetUnit(int aUnit)
SCH_PIN * GetLibPin() const
VECTOR2I GetPosition() const override
const wxString & GetShownName() const
void SetType(ELECTRICAL_PINTYPE aType)
ELECTRICAL_PINTYPE GetType() const
EE_RTREE & Items()
Get the full RTree, usually for iterating.
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Refresh a changed item in the tree and invalidate connectivity.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
std::vector< std::unique_ptr< SCH_PIN > > & GetRawPins()
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
int GetUnitCount() const override
Return the number of units per package of the symbol.
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
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_GROUND_PIN_NOT_GROUND
A ground-labeled pin is not on a ground net while another pin is.
@ 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)
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
std::vector< FAB_LAYER_COLOR > dummy
SETTINGS_MANAGER m_settingsManager
std::unique_ptr< SCHEMATIC > m_schematic
ERC_GROUND_PIN_TEST_FIXTURE()
@ VALUE
Field Value of part, i.e. "3.3K".
BOOST_FIXTURE_TEST_CASE(ERCGroundPinsUsePublishedNames, ERC_GROUND_PIN_TEST_FIXTURE)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
VECTOR3I expected(15, 30, 45)
BOOST_TEST_CONTEXT("Test Clearance")
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I