53 for(
int i = 0; i < aErrors.
GetCount(); ++i )
55 std::shared_ptr<ERC_ITEM> ercItem = std::static_pointer_cast<ERC_ITEM>( aErrors.
GetItem( i ) );
57 if( ercItem && ercItem->GetErrorCode() == aErrorCode )
70 std::vector<std::pair<wxString, int>> tests = { {
"issue16897", 3 } };
72 for(
const std::pair<wxString, int>&
test : tests )
88 m_schematic->ConnectionGraph()->RunERC();
98 "Expected " <<
test.second <<
" errors in " <<
test.first.ToStdString()
99 <<
" but got " << errors.
GetCount() <<
"\n"
110 std::vector<std::pair<wxString, int>> tests = { {
"similar_labels", 3 } };
112 for(
const std::pair<wxString, int>&
test : tests )
127 m_schematic->ConnectionGraph()->RunERC();
137 "Expected " <<
test.second <<
" errors in " <<
test.first.ToStdString()
138 <<
" but got " << errors.
GetCount() <<
"\n"
149 std::vector<std::pair<wxString, int>> tests = { {
"same_local_global_label", 1 } };
151 for(
const std::pair<wxString, int>&
test : tests )
165 m_schematic->ConnectionGraph()->RunERC();
175 "Expected " <<
test.second <<
" errors in " <<
test.first.ToStdString()
176 <<
" but got " << errors.
GetCount() <<
"\n"
197 m_schematic->ConnectionGraph()->RunERC();
207 "Expected 2 ERCE_SAME_LOCAL_GLOBAL_POWER violations\n"
211 "Expected 0 ERCE_SAME_LOCAL_GLOBAL_LABEL violations\n"
228 for(
const CASE&
test : { CASE{
"similar_labels",
true, 3 },
229 CASE{
"same_local_global_label",
false, 1 },
230 CASE{
"same_local_global_power",
false, 2 } } )
235 std::unique_ptr<SCHEMATIC> schematic;
238 schematic->RebuildConnectivity();
240 const auto run = [&]()
247 std::vector<std::string> markers;
251 std::vector<SCH_ITEM*> remove;
257 remove.push_back( item );
261 path.LastScreen()->DeleteItem( item );
264 std::sort( markers.begin(), markers.end() );
267 const auto legacy = run();
268 BOOST_REQUIRE_EQUAL( legacy.size(),
test.count );
270 schematic->RebuildConnectivity();
271 schematic->ConnectionGraph()->Reset();
272 const auto engine = run();
273 BOOST_TEST( engine == legacy, boost::test_tools::per_element() );
285 std::unique_ptr<SCHEMATIC> schematic;
287 std::vector<SCH_SHEET*> sheets;
290 sheets.push_back(
static_cast<SCH_SHEET*
>( item ) );
292 BOOST_REQUIRE_EQUAL( sheets.size(), 2u );
293 std::ranges::sort( sheets,
305 parent->GetScreen()->Append( nested );
306 schematic->RefreshHierarchy();
307 std::set<KIID_PATH> paths;
312 paths.insert(
path.Path() );
315 BOOST_REQUIRE_EQUAL( paths.size(), 2u );
316 const KIID_PATH shallow = *paths.begin();
321 std::unique_ptr<SCHEMATIC>
source;
339 local->
SetText( wxS(
"ERC_DEPTH_ORDER" ) );
340 global->SetText( wxS(
"ERC_DEPTH_ORDER" ) );
341 lower->SetText( wxS(
"erc_depth_order" ) );
343 BOOST_REQUIRE( lower->GetPosition() != global->GetPosition() );
347 const std::set<KIID> labels{ local->m_Uuid, global->m_Uuid, lower->m_Uuid };
349 for(
bool backend : {
false,
true } )
354 schematic->RebuildConnectivity();
363 const auto error = std::static_pointer_cast<ERC_ITEM>(
static_cast<SCH_MARKER*
>( item )->GetRCItem() );
365 if( error->GetMainItemID() == global->m_Uuid && error->GetAuxItemID() == local->m_Uuid )
367 BOOST_CHECK( error->GetMainItemSheetPath().PathRef() == shallow );
368 BOOST_CHECK( error->GetAuxItemSheetPath().PathRef() == shallow );
376 size_t crossSheet = 0;
377 size_t sameSheet = 0;
381 const auto error = std::static_pointer_cast<ERC_ITEM>(
static_cast<SCH_MARKER*
>( item )->GetRCItem() );
383 if( !labels.contains( error->GetMainItemID() ) || !labels.contains( error->GetAuxItemID() ) )
387 const auto&
main = error->GetMainItemSheetPath().PathRef();
388 const auto& aux = error->GetAuxItemSheetPath().PathRef();
393 BOOST_CHECK(
main == deep );
394 BOOST_CHECK( aux == shallow );
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
virtual void SetText(const wxString &aText)
EE_TYPE OfType(KICAD_T aType) const
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 TestSimilarLabels()
Checks for labels that differ only in capitalization.
int TestSameLocalGlobalLabel()
Checks for global and local labels with the same name.
wxString AsString() const
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCH_ITEM * Duplicate(bool addToParentGroup, SCH_COMMIT *aCommit=nullptr, bool aDoClone=false) const
Routine to create a new copy of given item.
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.
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
EE_RTREE & Items()
Get the full RTree, usually for iterating.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
SCH_SCREEN * GetScreen() const
VECTOR2I GetPosition() const override
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_SIMILAR_POWER
2 power pins are equal for case insensitive comparisons.
@ ERCE_SIMILAR_LABELS
2 labels are equal for case insensitive comparisons.
@ ERCE_SAME_LOCAL_GLOBAL_LABEL
2 labels are equal for case insensitive comparisons.
@ ERCE_SIMILAR_LABEL_AND_POWER
label and pin are equal for case insensitive comparisons.
@ ERCE_SAME_LOCAL_GLOBAL_POWER
Local power port and global power port have the same name.
@ ERCE_LABEL_SINGLE_PIN
A label is connected only to a single pin.
@ 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
std::unique_ptr< SCHEMATIC > m_schematic
SETTINGS_MANAGER m_settingsManager
ERC_REGRESSION_TEST_FIXTURE()
static int CountErrorCode(SHEETLIST_ERC_ITEMS_PROVIDER &aErrors, int aErrorCode)
BOOST_AUTO_TEST_CASE(ERCLabelNameChecksMatchLegacy)
BOOST_FIXTURE_TEST_CASE(ERCLabelCapitalization, ERC_REGRESSION_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")