KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_pad_numbering.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
20
#include <
qa_utils/wx_utils/unit_test_utils.h
>
21
#include <
board.h
>
22
#include <
footprint.h
>
23
#include <
pad.h
>
24
25
struct
PAD_FIXTURE
26
{
27
PAD_FIXTURE
() :
28
m_board
(),
29
m_footprint
( &
m_board
)
30
{
31
}
32
33
PAD
*
MakePTH
(
const
wxString& aNumber )
34
{
35
PAD
*
pad
=
new
PAD
( &
m_footprint
);
36
37
pad
->SetNumber( aNumber );
38
pad
->SetAttribute(
PAD_ATTRIB::PTH
);
39
pad
->SetLayerSet(
PAD::UnplatedHoleMask
() );
40
41
m_footprint
.Add(
pad
);
42
return
pad
;
43
}
44
45
PAD
*
MakeNPTH
()
46
{
47
PAD
*
pad
=
new
PAD
( &
m_footprint
);
48
49
pad
->SetAttribute(
PAD_ATTRIB::NPTH
);
50
pad
->SetLayerSet(
PAD::UnplatedHoleMask
() );
51
52
m_footprint
.Add(
pad
);
53
return
pad
;
54
}
55
56
PAD
*
MakeAperture
()
57
{
58
PAD
*
pad
=
new
PAD
( &
m_footprint
);
59
60
pad
->SetAttribute(
PAD_ATTRIB::PTH
);
61
pad
->SetLayerSet(
PAD::ApertureMask
() );
62
63
m_footprint
.Add(
pad
);
64
return
pad
;
65
}
66
67
PAD
*
MakeSmd
(
const
wxString& aNumber = wxEmptyString )
68
{
69
PAD
*
pad
=
new
PAD
( &
m_footprint
);
70
71
pad
->SetNumber( aNumber );
72
pad
->SetAttribute(
PAD_ATTRIB::SMD
);
73
pad
->SetLayerSet(
PAD::SMDMask
() );
74
75
m_footprint
.Add(
pad
);
76
return
pad
;
77
}
78
79
BOARD
m_board
;
80
FOOTPRINT
m_footprint
;
81
};
82
83
84
BOOST_FIXTURE_TEST_SUITE( PadNumbering,
PAD_FIXTURE
)
85
86
89
BOOST_AUTO_TEST_CASE
( CanNumber )
90
{
91
PAD
* npth = MakeNPTH();
92
BOOST_CHECK_EQUAL
(
false
, npth->
CanHaveNumber
() );
93
94
PAD
* aperture = MakeAperture();
95
BOOST_CHECK_EQUAL
(
false
, aperture->
CanHaveNumber
() );
96
97
PAD
* smd = MakeSmd();
98
BOOST_CHECK_EQUAL
(
true
, smd->
CanHaveNumber
() );
99
}
100
101
102
BOOST_AUTO_TEST_CASE
( TestPadCounting )
103
{
104
PAD
* p1 = MakeSmd(
"1"
);
105
PAD
* p2 = MakeSmd(
"2"
);
106
PAD
* p3 = MakeSmd(
"33"
);
107
PAD
* p4 = MakeSmd(
"AA12"
);
108
PAD
* p5 = MakeSmd(
"BC35"
);
109
PAD
* pXa = MakeSmd(
"AAA1"
);
110
PAD
* pXb = MakePTH(
"MP"
);
111
PAD
* pXc = MakeSmd(
"MP1a"
);
112
113
BOOST_CHECK_EQUAL
( m_footprint.GetNumberedPadCount(), 5 );
114
}
115
116
117
BOOST_AUTO_TEST_CASE
( TestUSBcPadCounting )
118
{
119
PAD
* p1_2 = MakeSmd(
"A1_B12"
);
120
PAD
* p3_4 = MakeSmd(
"A4_B9"
);
121
PAD
* p5 = MakeSmd(
"B8"
);
122
PAD
* p6 = MakeSmd(
"A5"
);
123
PAD
* p7 = MakeSmd(
"B7"
);
124
PAD
* p8 = MakeSmd(
"A6"
);
125
PAD
* p9 = MakeSmd(
"A7"
);
126
PAD
* p10 = MakeSmd(
"B6"
);
127
PAD
* p11 = MakeSmd(
"A8"
);
128
PAD
* p12 = MakeSmd(
"B5"
);
129
PAD
* p13_14 = MakeSmd(
"B4_A9"
);
130
PAD
* p15_16 = MakeSmd(
"B1_A12"
);
131
PAD
* p17a = MakeSmd(
"S1"
);
132
PAD
* p17b = MakeSmd(
"S1"
);
133
PAD
* p17c = MakeSmd(
"S1"
);
134
135
BOOST_CHECK_EQUAL
( m_footprint.GetNumberedPadCount(), 17 );
136
}
137
138
139
BOOST_AUTO_TEST_SUITE_END
()
ALTIUM_RECORD::PAD
@ PAD
Definition
altium_parser_pcb.h:142
BITMAPS::pad
@ pad
Definition
bitmaps_list.h:414
board.h
BOARD
Information pertinent to a Pcbnew printed circuit board.
Definition
board.h:409
FOOTPRINT
Definition
footprint.h:314
PAD
Definition
pad.h:61
PAD::CanHaveNumber
bool CanHaveNumber() const
Indicates whether or not the pad can have a number.
Definition
pad.cpp:524
PAD::UnplatedHoleMask
static LSET UnplatedHoleMask()
layer set for a mechanical unplated through hole pad
Definition
pad.cpp:627
PAD::ApertureMask
static LSET ApertureMask()
layer set for an aperture pad
Definition
pad.cpp:634
PAD::SMDMask
static LSET SMDMask()
layer set for a SMD pad on Front layer
Definition
pad.cpp:613
footprint.h
pad.h
PAD_ATTRIB::NPTH
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
Definition
padstack.h:102
PAD_ATTRIB::SMD
@ SMD
Smd pad, appears on the solder paste layer (default)
Definition
padstack.h:98
PAD_ATTRIB::PTH
@ PTH
Plated through hole pad.
Definition
padstack.h:97
PAD_FIXTURE
Definition
test_pad_numbering.cpp:26
PAD_FIXTURE::m_board
BOARD m_board
Definition
test_pad_numbering.cpp:79
PAD_FIXTURE::MakeAperture
PAD * MakeAperture()
Definition
test_pad_numbering.cpp:56
PAD_FIXTURE::MakePTH
PAD * MakePTH(const wxString &aNumber)
Definition
test_pad_numbering.cpp:33
PAD_FIXTURE::MakeSmd
PAD * MakeSmd(const wxString &aNumber=wxEmptyString)
Definition
test_pad_numbering.cpp:67
PAD_FIXTURE::MakeNPTH
PAD * MakeNPTH()
Definition
test_pad_numbering.cpp:45
PAD_FIXTURE::PAD_FIXTURE
PAD_FIXTURE()
Definition
test_pad_numbering.cpp:27
PAD_FIXTURE::m_footprint
FOOTPRINT m_footprint
Definition
test_pad_numbering.cpp:80
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
Definition
test_api_enums.cpp:79
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(CanNumber)
Check what gets names and what doesn't.
Definition
test_pad_numbering.cpp:89
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
unit_test_utils.h
src
qa
tests
pcbnew
test_pad_numbering.cpp
Generated on Thu Sep 17 2026 00:06:29 for KiCad PCB EDA Suite by
1.13.2