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
21#include <board.h>
22#include <footprint.h>
23#include <pad.h>
24
26{
28 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
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
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
81};
82
83
84BOOST_FIXTURE_TEST_SUITE( PadNumbering, PAD_FIXTURE )
85
86
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
102BOOST_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
117BOOST_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
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:409
Definition pad.h:61
bool CanHaveNumber() const
Indicates whether or not the pad can have a number.
Definition pad.cpp:524
static LSET UnplatedHoleMask()
layer set for a mechanical unplated through hole pad
Definition pad.cpp:627
static LSET ApertureMask()
layer set for an aperture pad
Definition pad.cpp:634
static LSET SMDMask()
layer set for a SMD pad on Front layer
Definition pad.cpp:613
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
Definition padstack.h:102
@ SMD
Smd pad, appears on the solder paste layer (default)
Definition padstack.h:98
@ PTH
Plated through hole pad.
Definition padstack.h:97
PAD * MakePTH(const wxString &aNumber)
PAD * MakeSmd(const wxString &aNumber=wxEmptyString)
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(CanNumber)
Check what gets names and what doesn't.
BOOST_CHECK_EQUAL(result, "25.4")