42 for(
int variant = 0; variant < 6; ++variant )
48 std::unique_ptr<SCHEMATIC> schematic;
51 std::set<KIID_PATH> paths;
55 if(
path.LastScreen()->GetFileName().EndsWith(
"LEDs.kicad_sch" ) )
58 screen =
path.LastScreen();
59 paths.insert(
path.PathRef() );
64 BOOST_REQUIRE_EQUAL( paths.size(), 2 );
71 bounds.
Merge( item->GetBoundingBox() );
74 labelSource =
static_cast<SCH_LABEL*
>( item );
78 auto* line =
static_cast<SCH_LINE*
>( item );
80 if( line->GetStartPoint() != line->GetEndPoint()
81 && ( !wireSource || item->
m_Uuid < wireSource->
m_Uuid ) )
93 label->SetText( variant == 1 || variant == 4 ?
"ERC_BUS[0..1]" :
"ERC_SIGNAL" );
100 bus->
SetText(
"ERC_BUS[0..1]" );
101 bus->SetPosition(
anchor );
107 line->
Move(
anchor - ( line->GetStartPoint() + line->GetEndPoint() ) / 2 );
117 extraBus->
SetText(
"ERC_BUS[0..1]" );
118 extraBus->SetPosition(
anchor );
119 screen->
Append( extraBus );
122 for(
auto& [code, severity] : schematic->ErcSettings().m_ERCSeverities )
126 using DIAGNOSTIC = std::tuple<KIID_PATH, KIID, KIID, int, int>;
127 std::set<KIID_PATH> excludedPaths;
128 const auto diagnostics = [&](
bool aRecordExclusions = false )
130 std::multiset<DIAGNOSTIC>
result;
131 std::vector<SCH_MARKER*> markers;
135 auto* marker =
static_cast<SCH_MARKER*
>( item );
136 const auto error = std::static_pointer_cast<ERC_ITEM>( marker->GetRCItem() );
138 if( error->GetMainItemID() == label->m_Uuid || error->GetMainItemID() == other->
m_Uuid )
141 BOOST_CHECK( !error->MainItemHasSheetPath() );
143 if( aRecordExclusions )
145 marker->SetExcluded(
true,
"Retained bus/net conflict" );
146 excludedPaths.insert( error->GetSpecificSheetPath().PathRef() );
149 const bool excluded = excludedPaths.contains( error->GetSpecificSheetPath().PathRef() );
153 BOOST_CHECK_EQUAL( marker->GetComment(), wxString(
"Retained bus/net conflict" ) );
155 result.emplace( error->GetSpecificSheetPath().PathRef(), error->GetMainItemID(),
156 error->GetAuxItemID(), marker->GetPosition().x, marker->GetPosition().y );
159 markers.push_back( marker );
162 if( aRecordExclusions )
163 schematic->RecordERCExclusions();
170 schematic->RebuildConnectivity();
171 schematic->ConnectionGraph()->RunERC();
172 const auto expected = diagnostics(
true );
174 if( variant < 3 || variant == 5 )
175 BOOST_REQUIRE_EQUAL(
expected.size(), 1 );
179 for(
bool backend : {
false,
true } )
182 schematic->RebuildConnectivity();
184 for(
bool clearLegacy : {
false,
true } )
187 if( clearLegacy && !backend )
191 schematic->ConnectionGraph()->Reset();
195 schematic->ConnectionGraph()->RunERC();
196 schematic->ResolveERCExclusionsPostUpdate();
197 BOOST_CHECK( diagnostics() ==
expected );
virtual void SetText(const wxString &aText)
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")