KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_fp_lib_load_save.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, 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
25#include <boost/test/data/test_case.hpp>
26
27#include <board.h>
28#include <kiid.h>
29#include <footprint.h>
33
34namespace
35{
36
37struct FPLIB_LOAD_FP_TEST_CASE
38{
39 // The FP to load
40 wxString m_libraryPath;
41 wxString m_fpName;
42
43 std::optional<unsigned> m_expectedFootprintVersion;
44
45 // If set, the expected number of pads in the footprint
46 std::optional<unsigned> m_expectedPadCount;
47
48 // For printing the test name
49 friend std::ostream& operator<<( std::ostream& os, const FPLIB_LOAD_FP_TEST_CASE& aTestCase )
50 {
51 os << aTestCase.m_fpName;
52 return os;
53 }
54};
55
56
57const std::vector<FPLIB_LOAD_FP_TEST_CASE> FpLibLoadSave_testCases{
58 {
59 "plugins/kicad_sexpr/fp.pretty",
60 "R_0201_0603Metric",
61 20240108U,
62 // 2 SMD pads, 2 paste pads
63 4U,
64 },
65};
66
67} // namespace
68
76BOOST_DATA_TEST_CASE( FpLibLoadSave, boost::unit_test::data::make( FpLibLoadSave_testCases ),
77 testCase )
78{
79 const auto doFootprintTest = [&]( const FOOTPRINT& aBoard )
80 {
81 if( testCase.m_expectedPadCount )
82 {
83 BOOST_CHECK_EQUAL( aBoard.Pads().size(), *testCase.m_expectedPadCount );
84 }
85 };
86
87 KI_TEST::LoadAndTestFootprintFile( testCase.m_libraryPath, testCase.m_fpName, true,
88 doFootprintTest, testCase.m_expectedFootprintVersion );
89}
General utilities for PCB file IO for QA programs.
std::ostream & operator<<(std::ostream &aStream, const EDA_TEXT &aText)
Definition: eda_text.cpp:1307
void LoadAndTestFootprintFile(const wxString &aLibRelativePath, const wxString &aFpName, bool aRoundtrip, std::function< void(FOOTPRINT &)> aFootprintTestFunction, std::optional< int > aExpectedFootprintVersion)
Same as LoadAndTestBoardFile, but for footprints.
BOOST_CHECK_EQUAL(ret, c.m_exp_result)
BOOST_DATA_TEST_CASE(FpLibLoadSave, boost::unit_test::data::make(FpLibLoadSave_testCases), testCase)
Simple tests cases that run though the given FPs and checks some simple properties.