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
25#include <memory>
29#include <boost/test/data/test_case.hpp>
30
33
34#include <board.h>
35#include <footprint.h>
36#include <pad.h>
37#include <zone.h>
38
39
47
48
52BOOST_FIXTURE_TEST_SUITE( AltiumPcbLibImport, ALTIUM_PCBLIB_IMPORT_FIXTURE )
53
54static const std::vector<std::tuple<wxString, wxString>> altium_to_kicad_footprint_property = {
55 { "Tracks.v5.PcbLib", "Tracks.pretty" },
56 { "Tracks.v6.PcbLib", "Tracks.pretty" },
57 { "Espressif ESP32-WROOM-32.PcbLib", "Espressif ESP32-WROOM-32.pretty" }
58};
59
63BOOST_DATA_TEST_CASE( AltiumPcbLibImport2,
64 boost::unit_test::data::make(altium_to_kicad_footprint_property),
65 altiumLibraryName,
66 kicadLibraryName )
67{
68 std::string dataPath = KI_TEST::GetPcbnewTestDataDir() + "plugins/altium/pcblib/";
69
70 wxString altiumLibraryPath = dataPath + altiumLibraryName;
71 wxString kicadLibraryPath = dataPath + kicadLibraryName;
72
73 wxArrayString altiumFootprintNames;
74 wxArrayString kicadFootprintNames;
75
76 altiumPlugin.FootprintEnumerate( altiumFootprintNames, altiumLibraryPath, true, nullptr );
77 kicadPlugin.FootprintEnumerate( kicadFootprintNames, kicadLibraryPath, true, nullptr );
78
79 BOOST_CHECK_EQUAL( altiumFootprintNames.GetCount(), kicadFootprintNames.GetCount() );
80
81 for( size_t i = 0; i < altiumFootprintNames.GetCount(); i++ )
82 {
83 wxString footprintName = altiumFootprintNames[i];
84
85 BOOST_TEST_CONTEXT( wxString::Format( wxT( "Import '%s' from '%s'" ), footprintName, altiumLibraryName ) )
86 {
87 std::unique_ptr<FOOTPRINT> altiumFp =
88 altiumPlugin.FootprintLoad( altiumLibraryPath, footprintName, false, nullptr );
89 BOOST_CHECK( altiumFp );
90
91 BOOST_CHECK_EQUAL( "REF**", altiumFp->GetReference() );
92 BOOST_CHECK_EQUAL( footprintName, altiumFp->GetValue() );
93
94 std::unique_ptr<FOOTPRINT> kicadFp =
95 kicadPlugin.FootprintLoad( kicadLibraryPath, footprintName, true, nullptr );
96 BOOST_CHECK( kicadFp );
97
98 if( !kicadFp )
99 continue;
100
101 KI_TEST::CheckFootprint( kicadFp.get(), altiumFp.get() );
102 }
103 }
104}
105
General utilities for PCB file IO for QA programs.
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")