KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_board_design_settings.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, you may find one here:
18
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19
* or you may search the http://www.gnu.org website for the version 2 license,
20
* or you may write to the Free Software Foundation, Inc.,
21
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22
*/
23
24
#include <
qa_utils/wx_utils/unit_test_utils.h
>
25
26
#include <
board.h
>
27
#include <
board_design_settings.h
>
28
#include <
drc/drc_engine.h
>
29
#include <
drc/drc_rule.h
>
30
#include <
settings/settings_manager.h
>
31
#include <
pcbnew_utils/board_test_utils.h
>
32
33
34
namespace
35
{
36
struct
BDS_TEST_FIXTURE
37
{
38
BDS_TEST_FIXTURE() :
39
m_board( new
BOARD
() )
40
{ }
41
42
SETTINGS_MANAGER m_settingsManager;
43
std::unique_ptr<BOARD> m_board;
44
};
45
}
// namespace
46
47
48
BOOST_FIXTURE_TEST_SUITE( BoardDesignSettings, BDS_TEST_FIXTURE )
49
50
51
58
BOOST_AUTO_TEST_CASE
( NegativeSilkClearanceRoundTrip )
59
{
60
BOARD_DESIGN_SETTINGS
& bds = m_board->GetDesignSettings();
61
62
int
negativeValue =
pcbIUScale
.mmToIU( -0.1 );
63
bds.
m_SilkClearance
= negativeValue;
64
65
// Store all params into the JSON backing store
66
bds.
Store
();
67
68
// Reset to default
69
bds.
m_SilkClearance
= 0;
70
71
// Load back from JSON
72
bds.
Load
();
73
74
BOOST_CHECK_EQUAL
( bds.
m_SilkClearance
, negativeValue );
75
}
76
77
87
BOOST_AUTO_TEST_CASE
( BiggestClearanceIncludesPhysicalHoleClearance )
88
{
89
BOARD_DESIGN_SETTINGS
& bds = m_board->GetDesignSettings();
90
91
// Larger than any default clearance, so it can only come from the rule below.
92
const
int
ruleClearance =
pcbIUScale
.mmToIU( 4.0 );
93
94
auto
rule = std::make_shared<DRC_RULE>( wxT(
"NPTH Hole to Track Clearance"
) );
95
96
DRC_CONSTRAINT
constraint(
PHYSICAL_HOLE_CLEARANCE_CONSTRAINT
);
97
constraint.
Value
().
SetMin
( ruleClearance );
98
rule->AddConstraint( constraint );
99
100
auto
engine = std::make_shared<DRC_ENGINE>( m_board.get(), &bds );
101
engine->InitEngine( rule );
102
bds.
m_DRCEngine
= engine;
103
104
BOOST_CHECK_GE( bds.
GetBiggestClearanceValue
(), ruleClearance );
105
}
106
107
108
BOOST_AUTO_TEST_SUITE_END
()
pcbIUScale
constexpr EDA_IU_SCALE pcbIUScale
Definition
base_units.h:125
board.h
board_design_settings.h
board_test_utils.h
BOARD_DESIGN_SETTINGS
Container for design settings for a BOARD object.
Definition
board_design_settings.h:253
BOARD_DESIGN_SETTINGS::m_DRCEngine
std::shared_ptr< DRC_ENGINE > m_DRCEngine
Definition
board_design_settings.h:725
BOARD_DESIGN_SETTINGS::GetBiggestClearanceValue
int GetBiggestClearanceValue() const
Definition
board_design_settings.cpp:1608
BOARD_DESIGN_SETTINGS::m_SilkClearance
int m_SilkClearance
Definition
board_design_settings.h:720
DRC_CONSTRAINT
Definition
drc_rule.h:170
DRC_CONSTRAINT::Value
MINOPTMAX< int > & Value()
Definition
drc_rule.h:201
JSON_SETTINGS::Load
virtual void Load()
Updates the parameters of this object based on the current JSON document contents.
Definition
json_settings.cpp:138
JSON_SETTINGS::Store
virtual bool Store()
Stores the current parameters into the JSON document represented by this object Note: this doesn't do...
Definition
json_settings.cpp:391
MINOPTMAX::SetMin
void SetMin(T v)
Definition
minoptmax.h:41
drc_engine.h
drc_rule.h
PHYSICAL_HOLE_CLEARANCE_CONSTRAINT
@ PHYSICAL_HOLE_CLEARANCE_CONSTRAINT
Definition
drc_rule.h:87
KICAD3D_MODEL_TYPE::BOARD
@ BOARD
Definition
kicad3d_info.h:35
settings_manager.h
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
Definition
test_api_enums.cpp:71
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(NegativeSilkClearanceRoundTrip)
Regression test for https://gitlab.com/kicad/code/kicad/-/issues/23327.
Definition
test_board_design_settings.cpp:58
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
unit_test_utils.h
src
qa
tests
pcbnew
test_board_design_settings.cpp
Generated on Sat Jun 6 2026 00:06:44 for KiCad PCB EDA Suite by
1.13.2