KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_generator_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 <pcb_generator.h>
33
34namespace
35{
36struct GENERATOR_LOAD_TEST_CASE
37{
38 // Which one to look at in the file?
39 KIID m_searchUuid;
40 // Expected values
41 bool m_expectedLocked;
42 wxString m_expectedName;
43 unsigned m_expectedMemberCount;
44};
45
46
47struct GENERATOR_LOAD_BOARD_TEST_CASE: public KI_TEST::BOARD_LOAD_TEST_CASE
48{
49 // List of images to check
50 std::vector<GENERATOR_LOAD_TEST_CASE> m_generatorCases;
51};
52
53const std::vector<GENERATOR_LOAD_BOARD_TEST_CASE> GeneratorLoading_testCases{
54 {
55 "tuning_generators_load_save",
56 20231231,
57 {
58 // From top to bottom in the board file
59 {
60 "4f22a815-3048-42b3-86fa-eb71720d35ae",
61 false,
62 "Tuning Pattern",
63 47,
64 },
65 },
66 },
67 {
68 // Before 20231231, 'id' was used in generator s-exprs
69 // and we need to continue to load it for compatibility
70 "tuning_generators_load_save_v20231212",
71 20231212,
72 {
73 // From top to bottom in the board file
74 {
75 "4f22a815-3048-42b3-86fa-eb71720d35ae",
76 false,
77 "Tuning Pattern",
78 47,
79 },
80 },
81 },
82};
83
84} // namespace
85
86BOOST_DATA_TEST_CASE( GeneratorLoading, boost::unit_test::data::make( GeneratorLoading_testCases ),
87 testCase )
88{
89 const auto doBoardTest = [&]( const BOARD& aBoard )
90 {
91 for( const GENERATOR_LOAD_TEST_CASE& testCase : testCase.m_generatorCases )
92 {
94 "Checking for generator with UUID: " << testCase.m_searchUuid.AsString() );
95
96 const auto& generator =
98 aBoard, PCB_GENERATOR_T, testCase.m_searchUuid ) );
99
100 BOOST_CHECK_EQUAL( generator.IsLocked(), testCase.m_expectedLocked );
101 BOOST_CHECK_EQUAL( generator.GetName(), testCase.m_expectedName );
102 BOOST_CHECK_EQUAL( generator.GetItems().size(), testCase.m_expectedMemberCount );
103 }
104 };
105
106 KI_TEST::LoadAndTestBoardFile( testCase.m_BoardFileRelativePath, true, doBoardTest,
107 testCase.m_ExpectedBoardVersion );
108}
General utilities for PCB file IO for QA programs.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:295
Definition: kiid.h:49
void LoadAndTestBoardFile(const wxString aRelativePath, bool aRoundtrip, std::function< void(BOARD &)> aBoardTestFunction, std::optional< int > aExpectedBoardVersion)
Perform "some test" on a board file loaded from the path, then optionally save and reload and run the...
BOARD_ITEM & RequireBoardItemWithTypeAndId(const BOARD &aBoard, KICAD_T aItemType, const KIID &aID)
Get an item from the given board with a certain type and UUID.
BOOST_CHECK_EQUAL(ret, c.m_exp_result)
BOOST_DATA_TEST_CASE(GeneratorLoading, boost::unit_test::data::make(GeneratorLoading_testCases), testCase)
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
Definition: typeinfo.h:91