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, see <https://www.gnu.org/licenses/>.
18 */
19
21#include <boost/test/data/test_case.hpp>
22
23#include <board.h>
24#include <kiid.h>
25#include <pcb_generator.h>
29
30namespace
31{
32struct GENERATOR_LOAD_TEST_CASE
33{
34 // Which one to look at in the file?
35 KIID m_searchUuid;
36 // Expected values
37 bool m_expectedLocked;
38 wxString m_expectedName;
39 unsigned m_expectedMemberCount;
40};
41
42
43struct GENERATOR_LOAD_BOARD_TEST_CASE: public KI_TEST::BOARD_LOAD_TEST_CASE
44{
45 // List of images to check
46 std::vector<GENERATOR_LOAD_TEST_CASE> m_generatorCases;
47};
48
49const std::vector<GENERATOR_LOAD_BOARD_TEST_CASE> GeneratorLoading_testCases{
50 {
51 "tuning_generators_load_save",
52 20231231,
53 {
54 // From top to bottom in the board file
55 {
56 "4f22a815-3048-42b3-86fa-eb71720d35ae",
57 false,
58 "Tuning Pattern",
59 47,
60 },
61 },
62 },
63 {
64 // Before 20231231, 'id' was used in generator s-exprs
65 // and we need to continue to load it for compatibility
66 "tuning_generators_load_save_v20231212",
67 20231212,
68 {
69 // From top to bottom in the board file
70 {
71 "4f22a815-3048-42b3-86fa-eb71720d35ae",
72 false,
73 "Tuning Pattern",
74 47,
75 },
76 },
77 },
78};
79
80} // namespace
81
82BOOST_DATA_TEST_CASE( GeneratorLoading, boost::unit_test::data::make( GeneratorLoading_testCases ),
83 testCase )
84{
85 const auto doBoardTest = [&]( const BOARD& aBoard )
86 {
87 for( const GENERATOR_LOAD_TEST_CASE& testCase : testCase.m_generatorCases )
88 {
90 "Checking for generator with UUID: " << testCase.m_searchUuid.AsString() );
91
92 const auto& generator =
94 aBoard, PCB_GENERATOR_T, testCase.m_searchUuid ) );
95
96 BOOST_CHECK_EQUAL( generator.IsLocked(), testCase.m_expectedLocked );
97 BOOST_CHECK_EQUAL( generator.GetName(), testCase.m_expectedName );
98 BOOST_CHECK_EQUAL( generator.GetItems().size(), testCase.m_expectedMemberCount );
99 }
100 };
101
102 KI_TEST::LoadAndTestBoardFile( testCase.m_BoardFileRelativePath, true, doBoardTest,
103 testCase.m_ExpectedBoardVersion );
104}
General utilities for PCB file IO for QA programs.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
wxString AsString() const
Definition kiid.cpp:242
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_DATA_TEST_CASE(GeneratorLoading, boost::unit_test::data::make(GeneratorLoading_testCases), testCase)
BOOST_TEST_MESSAGE("\n=== Real-World Polygon PIP Benchmark ===\n"<< formatTable(table))
BOOST_CHECK_EQUAL(result, "25.4")
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
Definition typeinfo.h:84