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 The 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
25
29
32
33#include <footprint.h>
34#include <pad.h>
35#include <zone.h>
36
37
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 BOOST_REQUIRE_NO_THROW(
72 cstarPlugin.FootprintEnumerate( cstarFootprintNames, cstarLibraryPath, true, nullptr ) );
73 BOOST_REQUIRE_NO_THROW(
74 kicadPlugin.FootprintEnumerate( kicadFootprintNames, kicadLibraryPath, true, nullptr ) );
75
76 BOOST_CHECK_EQUAL( cstarFootprintNames.GetCount(), kicadFootprintNames.GetCount() );
77
78 for( size_t i = 0; i < cstarFootprintNames.GetCount(); i++ )
79 {
80 wxString footprintName = cstarFootprintNames[i];
81
82 BOOST_TEST_CONTEXT( wxString::Format( wxT( "Import '%s' from '%s'" ),
83 footprintName,
84 libName.first ) )
85 {
86 FOOTPRINT* eagleFp = cstarPlugin.FootprintLoad( cstarLibraryPath, footprintName,
87 false, nullptr );
88 BOOST_CHECK( eagleFp );
89
90 BOOST_CHECK_EQUAL( "REF**", eagleFp->GetReference() );
91 BOOST_CHECK_EQUAL( footprintName, eagleFp->GetValue() );
92
93 FOOTPRINT* kicadFp = kicadPlugin.FootprintLoad( kicadLibraryPath, footprintName,
94 true, nullptr );
95 BOOST_CHECK( kicadFp );
96
97 KI_TEST::CheckFootprint( kicadFp, eagleFp );
98 }
99 }
100 }
101}
102
103
General utilities for PCB file IO for QA programs.
const wxString & GetValue() const
Definition footprint.h:683
const wxString & GetReference() const
Definition footprint.h:661
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(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE_END()
BOOST_TEST_CONTEXT("Test Clearance")
BOOST_CHECK_EQUAL(result, "25.4")