42struct ERC_REGRESSION_TEST_FIXTURE
44 ERC_REGRESSION_TEST_FIXTURE() {}
46 SETTINGS_MANAGER m_settingsManager;
47 std::unique_ptr<SCHEMATIC> m_schematic;
56 for(
int i = 0; i < aErrors.
GetCount(); ++i )
58 std::shared_ptr<ERC_ITEM> ercItem = std::static_pointer_cast<ERC_ITEM>( aErrors.
GetItem( i ) );
60 if( ercItem && ercItem->GetErrorCode() == aErrorCode )
73 std::vector<std::pair<wxString, int>> tests = { {
"issue16897", 3 } };
75 for(
const std::pair<wxString, int>&
test : tests )
91 m_schematic->ConnectionGraph()->RunERC();
101 "Expected " <<
test.second <<
" errors in " <<
test.first.ToStdString()
102 <<
" but got " << errors.
GetCount() <<
"\n"
113 std::vector<std::pair<wxString, int>> tests = { {
"similar_labels", 3 } };
115 for(
const std::pair<wxString, int>&
test : tests )
130 m_schematic->ConnectionGraph()->RunERC();
140 "Expected " <<
test.second <<
" errors in " <<
test.first.ToStdString()
141 <<
" but got " << errors.
GetCount() <<
"\n"
152 std::vector<std::pair<wxString, int>> tests = { {
"same_local_global_label", 1 } };
154 for(
const std::pair<wxString, int>&
test : tests )
168 m_schematic->ConnectionGraph()->RunERC();
178 "Expected " <<
test.second <<
" errors in " <<
test.first.ToStdString()
179 <<
" but got " << errors.
GetCount() <<
"\n"
200 m_schematic->ConnectionGraph()->RunERC();
210 "Expected 2 ERCE_SAME_LOCAL_GLOBAL_POWER violations\n"
214 "Expected 0 ERCE_SAME_LOCAL_GLOBAL_LABEL violations\n"
231 for(
const CASE&
test : { CASE{
"similar_labels",
true, 3 },
232 CASE{
"same_local_global_label",
false, 1 },
233 CASE{
"same_local_global_power",
false, 2 } } )
238 std::unique_ptr<SCHEMATIC> schematic;
241 schematic->RebuildConnectivity();
243 const auto run = [&]()
250 std::vector<std::string> markers;
254 std::vector<SCH_ITEM*> remove;
260 remove.push_back( item );
264 path.LastScreen()->DeleteItem( item );
267 std::sort( markers.begin(), markers.end() );
270 const auto legacy = run();
271 BOOST_REQUIRE_EQUAL( legacy.size(),
test.count );
273 schematic->RebuildConnectivity();
274 schematic->ConnectionGraph()->Reset();
275 const auto engine = run();
276 BOOST_TEST( engine == legacy, boost::test_tools::per_element() );
288 std::unique_ptr<SCHEMATIC> schematic;
290 std::vector<SCH_SHEET*> sheets;
293 sheets.push_back(
static_cast<SCH_SHEET*
>( item ) );
295 BOOST_REQUIRE_EQUAL( sheets.size(), 2u );
296 std::ranges::sort( sheets,
308 parent->GetScreen()->Append( nested );
309 schematic->RefreshHierarchy();
310 std::set<KIID_PATH> paths;
315 paths.insert(
path.Path() );
318 BOOST_REQUIRE_EQUAL( paths.size(), 2u );
319 const KIID_PATH shallow = *paths.begin();
324 std::unique_ptr<SCHEMATIC>
source;
342 local->
SetText( wxS(
"ERC_DEPTH_ORDER" ) );
343 global->SetText( wxS(
"ERC_DEPTH_ORDER" ) );
344 lower->SetText( wxS(
"erc_depth_order" ) );
346 BOOST_REQUIRE( lower->GetPosition() != global->GetPosition() );
350 const std::set<KIID> labels{ local->m_Uuid, global->m_Uuid, lower->m_Uuid };
352 for(
bool backend : {
false,
true } )
357 schematic->RebuildConnectivity();
366 const auto error = std::static_pointer_cast<ERC_ITEM>(
static_cast<SCH_MARKER*
>( item )->GetRCItem() );
368 if( error->GetMainItemID() == global->m_Uuid && error->GetAuxItemID() == local->m_Uuid )
370 BOOST_CHECK( error->GetMainItemSheetPath().PathRef() == shallow );
371 BOOST_CHECK( error->GetAuxItemSheetPath().PathRef() == shallow );
379 size_t crossSheet = 0;
380 size_t sameSheet = 0;
384 const auto error = std::static_pointer_cast<ERC_ITEM>(
static_cast<SCH_MARKER*
>( item )->GetRCItem() );
386 if( !labels.contains( error->GetMainItemID() ) || !labels.contains( error->GetAuxItemID() ) )
390 const auto&
main = error->GetMainItemSheetPath().PathRef();
391 const auto& aux = error->GetAuxItemSheetPath().PathRef();
396 BOOST_CHECK(
main == deep );
397 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
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")