KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_drc_net_chain_tuning_profiles.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
22#include <board.h>
24#include <drc/drc_engine.h>
25#include <drc/drc_engine.h>
26#include <drc/drc_item.h>
28
29
30namespace
31{
32struct DRC_REGRESSION_TEST_FIXTURE
33{
34 DRC_REGRESSION_TEST_FIXTURE() :
35 m_settingsManager()
36 {
37 }
38
39 SETTINGS_MANAGER m_settingsManager;
40 std::unique_ptr<BOARD> m_board;
41};
42} // namespace
43
44
45BOOST_FIXTURE_TEST_CASE( DRCNetChainTuningProfiles, DRC_REGRESSION_TEST_FIXTURE )
46{
47 std::vector<std::pair<wxString, int>> tests = {
48 { "drc_net_chain_tuning_profiles/test_drc_net_chain_tuning_profiles", 1 }
49 };
50
51 for( const std::pair<wxString, int>& test : tests )
52 {
53 KI_TEST::LoadBoard( m_settingsManager, test.first, m_board );
54 KI_TEST::FillZones( m_board.get() );
55
56 std::vector<DRC_ITEM> violations;
57 BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
58
59 // These DRC tests are not useful and do not work because they need a footprint library
60 // associated to the board
65
66 // Ensure that our desired error is fired
68
70 [&]( const std::shared_ptr<DRC_ITEM>& aItem, const VECTOR2I& aPos, int aLayer,
71 const std::function<void( PCB_MARKER* )>& aPathGenerator )
72 {
73 if( bds.GetSeverity( aItem->GetErrorCode() ) == SEVERITY::RPT_SEVERITY_ERROR )
74 violations.push_back( *aItem );
75 } );
76
77 bds.m_DRCEngine->RunTests( EDA_UNITS::MM, true, false );
78
79 if( violations.size() == test.second )
80 {
81 BOOST_CHECK_EQUAL( 1, 1 ); // quiet "did not check any assertions" warning
82 BOOST_TEST_MESSAGE( wxString::Format( "DRC net chain tuning profiles: %s, passed", test.first ) );
83 }
84 else
85 {
87
88 BOARD_RC_ITEM_RESOLVER resolver( *m_board );
89
90 for( const DRC_ITEM& item : violations )
91 {
92 BOOST_TEST_MESSAGE( item.ShowReport( &unitsProvider, RPT_SEVERITY_ERROR, resolver ) );
93 }
94
95 BOOST_ERROR(
96 wxString::Format( "DRC net chain tuning profiles: %s, failed (violations found %d expected %d)",
97 test.first, (int) violations.size(), test.second ) );
98 }
99 }
100}
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:128
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.
Definition drc_item.h:349
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).
Definition drc_engine.h:164
@ DRCE_LIB_FOOTPRINT_ISSUES
Definition drc_item.h:96
@ DRCE_INVALID_OUTLINE
Definition drc_item.h:86
@ DRCE_NET_CHAIN_TUNING_PROFILES
Definition drc_item.h:121
@ DRCE_DANGLING_VIA
Definition drc_item.h:59
@ DRCE_LIB_FOOTPRINT_MISMATCH
Definition drc_item.h:97
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
void FillZones(BOARD *m_board)
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_IGNORE
BOOST_FIXTURE_TEST_CASE(DRCNetChainTuningProfiles, DRC_REGRESSION_TEST_FIXTURE)
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708