KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_altium_pcblib_import.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
24
28#include <boost/test/data/test_case.hpp>
29
32
33#include <board.h>
34#include <footprint.h>
35#include <pad.h>
36#include <zone.h>
37
38
46
47
51BOOST_FIXTURE_TEST_SUITE( AltiumPcbLibImport, ALTIUM_PCBLIB_IMPORT_FIXTURE )
52
53static const std::vector<std::tuple<wxString, wxString>> altium_to_kicad_footprint_property = {
54 { "Tracks.v5.PcbLib", "Tracks.pretty" },
55 { "Tracks.v6.PcbLib", "Tracks.pretty" },
56 { "Espressif ESP32-WROOM-32.PcbLib", "Espressif ESP32-WROOM-32.pretty" }
57};
58
62BOOST_DATA_TEST_CASE( AltiumPcbLibImport2,
63 boost::unit_test::data::make(altium_to_kicad_footprint_property),
64 altiumLibraryName,
65 kicadLibraryName )
66{
67 std::string dataPath = KI_TEST::GetPcbnewTestDataDir() + "plugins/altium/pcblib/";
68
69 wxString altiumLibraryPath = dataPath + altiumLibraryName;
70 wxString kicadLibraryPath = dataPath + kicadLibraryName;
71
72 wxArrayString altiumFootprintNames;
73 wxArrayString kicadFootprintNames;
74
75 altiumPlugin.FootprintEnumerate( altiumFootprintNames, altiumLibraryPath, true, nullptr );
76 kicadPlugin.FootprintEnumerate( kicadFootprintNames, kicadLibraryPath, true, nullptr );
77
78 BOOST_CHECK_EQUAL( altiumFootprintNames.GetCount(), kicadFootprintNames.GetCount() );
79
80 for( size_t i = 0; i < altiumFootprintNames.GetCount(); i++ )
81 {
82 wxString footprintName = altiumFootprintNames[i];
83
84 BOOST_TEST_CONTEXT( wxString::Format( wxT( "Import '%s' from '%s'" ), footprintName,
85 altiumLibraryName ) )
86 {
87 FOOTPRINT* altiumFp = altiumPlugin.FootprintLoad( altiumLibraryPath, footprintName,
88 false, nullptr );
89 BOOST_CHECK( altiumFp );
90
91 BOOST_CHECK_EQUAL( "REF**", altiumFp->GetReference() );
92 BOOST_CHECK_EQUAL( footprintName, altiumFp->GetValue() );
93
94 FOOTPRINT* kicadFp = kicadPlugin.FootprintLoad( kicadLibraryPath, footprintName,
95 true, nullptr );
96 BOOST_CHECK( kicadFp );
97
98 if( !kicadFp )
99 continue;
100
101 KI_TEST::CheckFootprint( kicadFp, altiumFp );
102 }
103 }
104}
105
General utilities for PCB file IO for QA programs.
const wxString & GetValue() const
Definition footprint.h:863
const wxString & GetReference() const
Definition footprint.h:841
A #PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
void CheckFootprint(const FOOTPRINT *expected, const FOOTPRINT *fp)
Helper method to check if two footprints are semantically the same.
STL namespace.
BOOST_DATA_TEST_CASE(AltiumPcbLibImport2, boost::unit_test::data::make(altium_to_kicad_footprint_property), altiumLibraryName, kicadLibraryName)
Compare all footprints declared in a *.PcbLib file with their KiCad reference footprint.
static const std::vector< std::tuple< wxString, wxString > > altium_to_kicad_footprint_property
Declares the struct as the Boost test fixture.
BOOST_AUTO_TEST_SUITE_END()
BOOST_TEST_CONTEXT("Test Clearance")
BOOST_CHECK_EQUAL(result, "25.4")