KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_eagle_lbr_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 (C) 2022-2023 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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
32
35
36#include <footprint.h>
37#include <pad.h>
38#include <zone.h>
39
40
42{
44
47};
48
49
53BOOST_FIXTURE_TEST_SUITE( EagleLbrLibImport, EAGLE_LBR_IMPORT_FIXTURE )
54
55
56
59BOOST_AUTO_TEST_CASE( EagleLbrLibImport )
60{
61 // clang-format off
62 std::vector<std::pair<wxString, wxString>> tests = {
63 { "SparkFun-GPS.lbr", "SparkFun-GPS.pretty" }
64 };
65 // clang-format on
66
67 std::string dataPath = KI_TEST::GetPcbnewTestDataDir() + "plugins/eagle/lbr/";
68
69 for( const std::pair<wxString, wxString>& libName : tests )
70 {
71 wxString eagleLibraryPath = dataPath + libName.first;
72 wxString kicadLibraryPath = dataPath + libName.second;
73
74 wxArrayString eagleFootprintNames;
75 wxArrayString kicadFootprintNames;
76
77 eaglePlugin.FootprintEnumerate( eagleFootprintNames, eagleLibraryPath, true, nullptr );
78 kicadPlugin.FootprintEnumerate( kicadFootprintNames, kicadLibraryPath, true, nullptr );
79
80 BOOST_CHECK_EQUAL( eagleFootprintNames.GetCount(), kicadFootprintNames.GetCount() );
81
82 for( size_t i = 0; i < eagleFootprintNames.GetCount(); i++ )
83 {
84 wxString footprintName = eagleFootprintNames[i];
85
86 BOOST_TEST_CONTEXT( wxString::Format( wxT( "Import '%s' from '%s'" ), footprintName,
87 libName.first ) )
88 {
89 FOOTPRINT* eagleFp = eaglePlugin.FootprintLoad( eagleLibraryPath, footprintName,
90 false, nullptr );
91 BOOST_CHECK( eagleFp );
92
93 BOOST_CHECK_EQUAL( "REF**", eagleFp->GetReference() );
94 BOOST_CHECK_EQUAL( footprintName, eagleFp->GetValue() );
95
96 FOOTPRINT* kicadFp = kicadPlugin.FootprintLoad( kicadLibraryPath, footprintName,
97 true, nullptr );
98 BOOST_CHECK( kicadFp );
99
100 KI_TEST::CheckFootprint( kicadFp, eagleFp );
101 }
102 }
103 }
104}
105
106
General utilities for PCB file IO for QA programs.
const wxString & GetValue() const
Definition: footprint.h:644
const wxString & GetReference() const
Definition: footprint.h:622
Works with Eagle 6.x XML board files and footprints to implement the Pcbnew #PLUGIN API or a portion ...
Definition: pcb_io_eagle.h:133
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.
BOOST_AUTO_TEST_CASE(EagleLbrLibImport)
Declares the struct as the Boost test fixture.
BOOST_AUTO_TEST_SUITE_END()