40struct DRC_REGRESSION_TEST_FIXTURE
42 DRC_REGRESSION_TEST_FIXTURE()
45 SETTINGS_MANAGER m_settingsManager;
46 std::unique_ptr<BOARD> m_board;
55 std::vector<std::pair<wxString, int>> tests =
57 {
"skew_within_diff_pairs_drc", 2 },
58 {
"skew_group_matched_drc", 5 }
61 for(
const std::pair<wxString, int>&
test : tests )
66 std::vector<DRC_ITEM> violations;
85 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
86 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
89 violations.push_back( *aItem );
94 if( violations.size() ==
test.second )
105 for(
const DRC_ITEM& item : violations )
111 BOOST_ERROR( wxString::Format(
"DRC skew: %s, failed (violations found %d expected %d)",
112 test.first, (
int)violations.size(),
test.second ) );
119 const wxString& aMin,
const wxString& aMax,
const std::string& aTmpSubdir )
121 namespace fs = std::filesystem;
125 fs::path druPath = tmpDir.
Path() /
"skew.kicad_dru";
128 std::ofstream druOut( druPath );
129 druOut << wxString::Format(
"(version 1)\n"
131 " (constraint skew (min %smm) (max %smm) (within_diff_pairs))\n"
132 " (condition \"A.inDiffPair('*')\")\n"
142 auto drcEngine = std::make_shared<DRC_ENGINE>( aBoard.get(), &bds );
143 wxFileName ruleFile( druPath.string() );
144 drcEngine->InitEngine( ruleFile );
155 size_t violations = 0;
157 drcEngine->SetViolationHandler(
158 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I&,
int,
168 fs::remove( druPath, ec );
179 runInlineSkewRule( m_settingsManager, m_board, wxS(
"0.05" ), wxS(
"0.55" ),
"kicad_drc_skew_min_ref" );
181 BOOST_CHECK_MESSAGE( violations == 0,
"Expected no violation, got " << violations );
190 runInlineSkewRule( m_settingsManager, m_board, wxS(
"0.45" ), wxS(
"0.55" ),
"kicad_drc_skew_min_under" );
192 BOOST_CHECK_MESSAGE( violations == 1,
"Expected one violation, got " << violations );
constexpr EDA_IU_SCALE pcbIUScale
Container for design settings for a BOARD object.
std::map< int, SEVERITY > m_DRCSeverities
std::shared_ptr< DRC_ENGINE > m_DRCEngine
SEVERITY GetSeverity(int aDRCErrorCode) const
Return the severity of a given DRC error code.
Implements the RC_ITEM_RESOLVER interface to resolve PCB items by their KIID.
void RunTests(EDA_UNITS aUnits, bool aReportAllTrackErrors, bool aTestFootprints, BOARD_COMMIT *aCommit=nullptr)
Run the DRC tests.
void SetViolationHandler(DRC_VIOLATION_HANDLER aHandler)
Set an optional DRC violation handler (receives DRC_ITEMs and positions).
const std::filesystem::path & Path() const
Get the path to the temporary directory as a std::filesystem::path.
@ DRCE_LIB_FOOTPRINT_ISSUES
@ DRCE_DRILL_OUT_OF_RANGE
@ DRCE_LIB_FOOTPRINT_MISMATCH
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
void FillZones(BOARD *m_board)
static size_t runInlineSkewRule(SETTINGS_MANAGER &aSettingsManager, std::unique_ptr< BOARD > &aBoard, const wxString &aMin, const wxString &aMax, const std::string &aTmpSubdir)
BOOST_FIXTURE_TEST_CASE(DRCSkew, DRC_REGRESSION_TEST_FIXTURE)
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I