KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_exchange_pad_changes.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
23#include <board.h>
24#include <footprint.h>
25#include <footprint_utils.h>
26
27
29{
30 std::unique_ptr<FOOTPRINT> load( const wxString& aName )
31 {
32 std::unique_ptr<FOOTPRINT> fp = KI_TEST::ReadFootprintFromFile(
33 KI_TEST::GetPcbnewTestDataDir() + "exchange_pad_changes.pretty", aName );
34
35 BOOST_REQUIRE( fp );
36 return fp;
37 }
38
39 // Placement on the board must never read as a pad change
40 std::unique_ptr<FOOTPRINT> placeOnBack( const FOOTPRINT& aLibrary )
41 {
42 std::unique_ptr<FOOTPRINT> placed( static_cast<FOOTPRINT*>( aLibrary.Clone() ) );
43 placed->SetParent( &m_board );
44 placed->SetPosition( VECTOR2I( 25400000, 12700000 ) );
45 placed->SetOrientation( ANGLE_90 );
46 placed->Flip( placed->GetPosition(), FLIP_DIRECTION::LEFT_RIGHT );
47 return placed;
48 }
49
51};
52
53
54BOOST_FIXTURE_TEST_SUITE( ExchangePadChanges, EXCHANGE_PAD_CHANGES_FIXTURE )
55
56
57// Rev 1 is the campaign's acme footprint; Rev 2 is the stock P7.62 variant with pad 2 moved
58BOOST_AUTO_TEST_CASE( PadMoveIsCounted )
59{
60 std::unique_ptr<FOOTPRINT> rev1 = load( wxS( "R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal" ) );
61 std::unique_ptr<FOOTPRINT> rev2 = load( wxS( "R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_Horizontal" ) );
62 std::unique_ptr<FOOTPRINT> placed = placeOnBack( *rev1 );
63
64 BOOST_TEST( !ComparePads( *placed, *rev1 ).Any() );
65
66 PAD_CHANGE_SUMMARY changes = ComparePads( *placed, *rev2 );
67 BOOST_TEST( changes.moved == 1 );
68 BOOST_TEST( changes.added == 0 );
69 BOOST_TEST( changes.removed == 0 );
70}
71
72
73// Thermal vias reuse the exposed pad's number and the paste pads have none
74BOOST_AUTO_TEST_CASE( SharedPadNumbersPairByPosition )
75{
76 std::unique_ptr<FOOTPRINT> plain = load( wxS( "HSOP-8-1EP_3.9x4.9mm_P1.27mm_EP2.3x2.3mm" ) );
77 std::unique_ptr<FOOTPRINT> vias = load( wxS( "HSOP-8-1EP_3.9x4.9mm_P1.27mm_EP2.3x2.3mm_ThermalVias" ) );
78 std::unique_ptr<FOOTPRINT> placed = placeOnBack( *plain );
79
80 BOOST_TEST( !ComparePads( *placed, *plain ).Any() );
81
82 PAD_CHANGE_SUMMARY changes = ComparePads( *placed, *vias );
83 BOOST_TEST( changes.moved == 0 );
84 BOOST_TEST( changes.added == 5 );
85 BOOST_TEST( changes.removed == 0 );
86}
87
88
General utilities for PCB file IO for QA programs.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
static constexpr EDA_ANGLE ANGLE_90
Definition eda_angle.h:474
PAD_CHANGE_SUMMARY ComparePads(const FOOTPRINT &aPlaced, const FOOTPRINT &aLibrary)
Count the pads that exchanging aPlaced for aLibrary would move, add or remove.
Collection of reusable/testable functions for footprint manipulation and validation.
@ LEFT_RIGHT
Flip left to right (around the Y axis)
Definition mirror.h:27
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
std::unique_ptr< FOOTPRINT > ReadFootprintFromFile(const std::filesystem::path &aFilename, const wxString &aFootprintName)
Read a footprint object aFootprintName from aFileName.
std::unique_ptr< FOOTPRINT > load(const wxString &aName)
std::unique_ptr< FOOTPRINT > placeOnBack(const FOOTPRINT &aLibrary)
Pad differences between a placed footprint and the library footprint that would replace it.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_REQUIRE(res.columns()==1)
BOOST_AUTO_TEST_CASE(PadMoveIsCounted)
BOOST_AUTO_TEST_SUITE_END()
BOOST_TEST(netlist.find("R_G1 ARM_OUT1 DIE_B R='0.001 / ((SW_STATE)") !=std::string::npos)
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708