55 using DIAGNOSTIC = std::tuple<KIID, KIID_PATH, int, int, wxString>;
57 for(
const wxString& fixture : { wxString(
"erc_wire_endpoints" ), wxString(
"unconnected_bus_entry_qa" ) } )
64 for(
auto& [code, severity] : m_schematic->ErcSettings().m_ERCSeverities )
68 m_schematic->ConnectionGraph()->RunERC();
70 const auto diagnostics = [&](
bool aRecordExclusions = false )
73 std::multiset<DIAGNOSTIC>
result;
74 std::vector<std::pair<SCH_SCREEN*, SCH_MARKER*>> markers;
76 for(
int i = 0; i < errors.
GetCount(); ++i )
78 const auto item = std::static_pointer_cast<ERC_ITEM>( errors.
GetItem( i ) );
79 auto* marker =
static_cast<SCH_MARKER*
>( item->GetParent() );
81 if( aRecordExclusions )
84 BOOST_CHECK( marker->IsExcluded() );
87 result.emplace( item->GetMainItemID(), item->GetSpecificSheetPath().PathRef(),
88 marker->GetPosition().x, marker->GetPosition().y, item->GetErrorMessage(
false ) );
89 markers.emplace_back( item->GetSpecificSheetPath().LastScreen(), marker );
92 if( aRecordExclusions )
93 m_schematic->RecordERCExclusions();
95 for(
const auto& [screen, marker] : markers )
96 screen->DeleteItem( marker );
100 const auto expected = diagnostics(
true );
103 m_schematic->RebuildConnectivity();
105 std::set<SCH_SCREEN*> screens;
106 size_t markerCount = 0;
110 if( screens.insert(
path.LastScreen() ).second )
118 m_schematic->ResolveERCExclusionsPostUpdate();
119 BOOST_CHECK( diagnostics() ==
expected );
130 using GROUP = std::pair<KIID_PATH, std::vector<KIID>>;
132 for(
const wxString& fixture : { wxString(
"erc_wire_endpoints" ), wxString(
"unconnected_bus_entry_qa" ) } )
139 for(
auto& [code, severity] : m_schematic->ErcSettings().m_ERCSeverities )
143 std::map<KIID, VECTOR2I> positions;
148 positions.emplace( item->m_Uuid, item->GetPosition() );
152 const auto diagnostics = [&](
bool aCanonical )
155 std::multiset<GROUP>
result;
156 std::vector<std::pair<SCH_SCREEN*, SCH_MARKER*>> markers;
158 for(
int i = 0; i < errors.
GetCount(); ++i )
160 const auto item = std::static_pointer_cast<ERC_ITEM>( errors.
GetItem( i ) );
161 auto* marker =
static_cast<SCH_MARKER*
>( item->GetParent() );
163 auto ids = item->GetIDs();
169 BOOST_CHECK( std::is_sorted( ids.begin(), ids.end() ) );
170 BOOST_CHECK( marker->GetPosition() == positions.at( ids.front() ) );
171 BOOST_CHECK( marker->IsExcluded() );
176 marker->SetExcluded(
true,
"Retained floating wire" );
179 std::sort( ids.begin(), ids.end() );
180 result.emplace( item->GetSpecificSheetPath().PathRef(), std::move( ids ) );
181 markers.emplace_back( item->GetSpecificSheetPath().LastScreen(), marker );
185 m_schematic->RecordERCExclusions();
187 for(
const auto& [screen, marker] : markers )
188 screen->DeleteItem( marker );
192 m_schematic->ConnectionGraph()->RunERC();
193 const auto expected = diagnostics(
false );
196 m_schematic->RebuildConnectivity();
197 m_schematic->ConnectionGraph()->Reset();
199 m_schematic->ResolveERCExclusionsPostUpdate();
200 BOOST_CHECK( diagnostics(
true ) ==
expected );
213 std::vector<std::pair<wxString, int>> tests = { {
"erc_wire_endpoints", 4 } };
215 for(
const std::pair<wxString, int>&
test : tests )
230 m_schematic->ConnectionGraph()->RunERC();
237 "Expected " <<
test.second <<
" errors in " <<
test.first.ToStdString()
238 <<
" but got " << errors.
GetCount() <<
"\n"
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")