KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_netlist_exporter_kicad.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 modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
21#include <eeschema_test_utils.h>
22
23
25{
26public:
27 void CompareNetlists() override
28 {
29 NETLIST golden;
31
32 {
33 std::unique_ptr<NETLIST_READER> netlistReader( NETLIST_READER::GetNetlistReader(
34 &golden, GetNetlistPath(), wxEmptyString ) );
35
36 BOOST_ASSERT( netlistReader );
37 BOOST_REQUIRE_NO_THROW( netlistReader->LoadNetlist() );
38 }
39
40 {
41 std::unique_ptr<NETLIST_READER> netlistReader( NETLIST_READER::GetNetlistReader(
42 &test, GetNetlistPath( true ), wxEmptyString ) );
43
44 BOOST_ASSERT( netlistReader );
45 BOOST_REQUIRE_NO_THROW( netlistReader->LoadNetlist() );
46 }
47
48 // Number of components should match
49 BOOST_REQUIRE_EQUAL( golden.GetCount(), test.GetCount() );
50
51 for( unsigned i = 0; i < golden.GetCount(); i++ )
52 {
53 COMPONENT* goldenComp = golden.GetComponent( i );
54 COMPONENT* refComp = test.GetComponentByReference( goldenComp->GetReference() );
55
56 // Retrieval by reference
57 BOOST_REQUIRE_NE( refComp, nullptr );
58
59 // Retrieval by KIID
60 KIID_PATH path = goldenComp->GetPath();
61
62 BOOST_REQUIRE( !goldenComp->GetKIIDs().empty() );
63
64 path.push_back( goldenComp->GetKIIDs().front() );
65
66 COMPONENT* pathComp = test.GetComponentByPath( path );
67 BOOST_REQUIRE_NE( pathComp, nullptr );
68
69 // We should have found the same component
70 BOOST_REQUIRE_EQUAL( refComp->GetReference(), pathComp->GetReference() );
71
72 // And that component should have the same number of attached nets
73 BOOST_REQUIRE_EQUAL( goldenComp->GetNetCount(), refComp->GetNetCount() );
74
75 for( unsigned net = 0; net < goldenComp->GetNetCount(); net++ )
76 {
77 const COMPONENT_NET& goldenNet = goldenComp->GetNet( net );
78 const COMPONENT_NET& testNet = refComp->GetNet( net );
79
80 // The video test has a bunch of unconnected RESERVED pins which cause duplicate
81 // auto-generated netnames. The connectivity algo disambiguates these with "_n"
82 // suffixes, but since the algorithm is multi-threaded, which ones get which suffix
83 // is not deterministic. So skip these.
84 if( testNet.GetPinFunction().Contains( "RESERVED" ) )
85 continue;
86
87 // The two nets at the same index should be identical
88 BOOST_REQUIRE_EQUAL( goldenNet.GetNetName(), testNet.GetNetName() );
89 BOOST_REQUIRE_EQUAL( goldenNet.GetPinName(), testNet.GetPinName() );
90 BOOST_REQUIRE_EQUAL( goldenNet.GetPinType(), testNet.GetPinType() );
91 }
92
93 // And the the resolved component class is the same
95 == refComp->GetComponentClassNames() );
96 }
97 }
98};
99
100
101BOOST_FIXTURE_TEST_SUITE( Netlists, TEST_NETLIST_EXPORTER_KICAD_FIXTURE )
102
103
105{
106 BOOST_CHECK_NE( m_pi.get(), nullptr );
107}
108
109
110BOOST_AUTO_TEST_CASE( GlobalPromotion )
111{
112 TestNetlist( "test_global_promotion" );
113}
114
115
116BOOST_AUTO_TEST_CASE( GlobalPromotion2 )
117{
118 TestNetlist( "test_global_promotion_2" );
119}
120
121
123{
124 TestNetlist( "video" );
125}
126
127
128BOOST_AUTO_TEST_CASE( ComplexHierarchy )
129{
130 TestNetlist( "complex_hierarchy" );
131}
132
133
134BOOST_AUTO_TEST_CASE( WeakVectorBusDisambiguation )
135{
136 TestNetlist( "weak_vector_bus_disambiguation" );
137}
138
139
140BOOST_AUTO_TEST_CASE( BusJunctions )
141{
142 TestNetlist( "bus_junctions" );
143}
144
145
146BOOST_AUTO_TEST_CASE( HierRenaming )
147{
148 TestNetlist( "test_hier_renaming" );
149}
150
151
153{
154 TestNetlist( "noconnects" );
155}
156
157
158BOOST_AUTO_TEST_CASE( PrefixBusAlias )
159{
160 TestNetlist( "prefix_bus_alias" );
161}
162
163
164BOOST_AUTO_TEST_CASE( GroupBusMatching )
165{
166 TestNetlist( "group_bus_matching" );
167}
168
169
170BOOST_AUTO_TEST_CASE( TopLevelHierPins )
171{
172 TestNetlist( "top_level_hier_pins" );
173}
174
175
177{
178 TestNetlist( "bus_entries" );
179}
180
181
182BOOST_AUTO_TEST_CASE( HierNoConnect )
183{
184 TestNetlist( "test_hier_no_connect" );
185}
186
187
188BOOST_AUTO_TEST_CASE( BusConnection )
189{
190 TestNetlist( "bus_connection" );
191}
192
194{
195 TestNetlist( "issue14657" );
196}
197
198BOOST_AUTO_TEST_CASE( HierarchyAliases )
199{
200 TestNetlist( "hierarchy_aliases" );
201}
202
204{
205 TestNetlist( "issue14818" );
206}
207
209{
210 TestNetlist( "issue16003" );
211}
212
214{
215 TestNetlist( "issue16439" );
216}
217
218BOOST_AUTO_TEST_CASE( ComponentClasses )
219{
220 TestNetlist( "component_classes" );
221}
222
223
225{
226 TestNetlist( "jumpers" );
227}
228
229
Used to store the component pin name to net name (and pin function) associations stored in a netlist.
const wxString & GetNetName() const
const wxString & GetPinFunction() const
const wxString & GetPinName() const
const wxString & GetPinType() const
Store all of the related component information found in a netlist.
const COMPONENT_NET & GetNet(unsigned aIndex) const
const KIID_PATH & GetPath() const
const wxString & GetReference() const
const std::vector< KIID > & GetKIIDs() const
unsigned GetNetCount() const
std::unordered_set< wxString > & GetComponentClassNames()
static NETLIST_READER * GetNetlistReader(NETLIST *aNetlist, const wxString &aNetlistFileName, const wxString &aCompFootprintFileName=wxEmptyString)
Attempt to determine the net list file type of aNetlistFileName and return the appropriate NETLIST_RE...
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
unsigned GetCount() const
COMPONENT * GetComponent(unsigned aIndex)
Return the COMPONENT at aIndex.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(FindPlugin)