KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_cadstar_footprints.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) 2023 Roberto Fernandez Bautista <[email protected]>
5 * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
29
32
33#include <footprint.h>
34#include <pad.h>
35#include <zone.h>
36
37
39{
41
44};
45
46
47BOOST_FIXTURE_TEST_SUITE( CadstarFootprintsImport, CADSTAR_IMPORT_FIXTURE )
48
49
50
55BOOST_AUTO_TEST_CASE( CadstarFootprintImport )
56{
57 std::vector<std::pair<wxString, wxString>> tests = {
58 { "footprint-with-thermal-pad.cpa", "footprint-with-thermal-pad.pretty" }
59 };
60
61 std::string dataPath = KI_TEST::GetPcbnewTestDataDir() + "plugins/cadstar/lib/";
62
63 for( const std::pair<wxString, wxString>& libName : tests )
64 {
65 wxString cstarLibraryPath = dataPath + libName.first;
66 wxString kicadLibraryPath = dataPath + libName.second;
67
68 wxArrayString cstarFootprintNames;
69 wxArrayString kicadFootprintNames;
70
71 cstarPlugin.FootprintEnumerate( cstarFootprintNames, cstarLibraryPath, true, nullptr );
72 kicadPlugin.FootprintEnumerate( kicadFootprintNames, kicadLibraryPath, true, nullptr );
73
74 BOOST_CHECK_EQUAL( cstarFootprintNames.GetCount(), kicadFootprintNames.GetCount() );
75
76 for( size_t i = 0; i < cstarFootprintNames.GetCount(); i++ )
77 {
78 wxString footprintName = cstarFootprintNames[i];
79
80 BOOST_TEST_CONTEXT( wxString::Format( wxT( "Import '%s' from '%s'" ), footprintName,
81 libName.first ) )
82 {
83 FOOTPRINT* eagleFp = cstarPlugin.FootprintLoad( cstarLibraryPath, footprintName,
84 false, nullptr );
85 BOOST_CHECK( eagleFp );
86
87 BOOST_CHECK_EQUAL( "REF**", eagleFp->GetReference() );
88 BOOST_CHECK_EQUAL( footprintName, eagleFp->GetValue() );
89
90 FOOTPRINT* kicadFp =
91 kicadPlugin.FootprintLoad( kicadLibraryPath, footprintName, true, nullptr );
92 BOOST_CHECK( kicadFp );
93
94 KI_TEST::CheckFootprint( kicadFp, eagleFp );
95 }
96 }
97 }
98}
99
100
General utilities for PCB file IO for QA programs.
const wxString & GetValue() const
Definition: footprint.h:624
const wxString & GetReference() const
Definition: footprint.h:602
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.
PCB_IO_CADSTAR_ARCHIVE cstarPlugin
BOOST_AUTO_TEST_CASE(CadstarFootprintImport)
Compare all footprints with their KiCad reference footprint TODO: Refactor this code so it can be mad...
BOOST_AUTO_TEST_SUITE_END()