KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_variant_symbol_compatibility.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
26#include <lib_symbol.h>
27#include <sch_pin.h>
28#include <sch_symbol.h>
30
31
32namespace
33{
34
39void AddPin( LIB_SYMBOL& aSymbol, const wxString& aNumber, const VECTOR2I& aPos,
41 int aUnit = 1, int aBodyStyle = 1 )
42{
43 SCH_PIN* pin = new SCH_PIN( &aSymbol );
44 pin->SetNumber( aNumber );
45 pin->SetPosition( aPos );
46 pin->SetType( aType );
47 pin->SetUnit( aUnit );
48 pin->SetBodyStyle( aBodyStyle );
49 aSymbol.AddDrawItem( pin );
50}
51
52
56std::unique_ptr<LIB_SYMBOL> MakeTwoPinPassive( const wxString& aName )
57{
58 auto sym = std::make_unique<LIB_SYMBOL>( aName );
59 AddPin( *sym, wxS( "1" ), VECTOR2I( 0, 0 ) );
60 AddPin( *sym, wxS( "2" ), VECTOR2I( 0, 5080000 ) );
61 return sym;
62}
63
64
65bool HasError( const std::vector<VARIANT_COMPAT_RESULT>& aResults, VARIANT_COMPAT_ERROR aError )
66{
67 for( const VARIANT_COMPAT_RESULT& r : aResults )
68 {
69 if( r.error == aError )
70 return true;
71 }
72
73 return false;
74}
75
76
77bool HasErrorForPin( const std::vector<VARIANT_COMPAT_RESULT>& aResults,
78 VARIANT_COMPAT_ERROR aError, const wxString& aPin )
79{
80 for( const VARIANT_COMPAT_RESULT& r : aResults )
81 {
82 if( r.error == aError && r.pinNumber == aPin )
83 return true;
84 }
85
86 return false;
87}
88
89} // anonymous namespace
90
91
92BOOST_AUTO_TEST_SUITE( VariantSymbolCompatibility )
93
94
95BOOST_AUTO_TEST_CASE( IdenticalSymbols_Compatible )
96{
97 auto base = MakeTwoPinPassive( wxS( "R_100R" ) );
98 auto candidate = MakeTwoPinPassive( wxS( "R_100R" ) );
99
100 auto results = ValidateVariantSymbolCompatibility( *base, *candidate );
101
102 BOOST_CHECK( results.empty() );
103}
104
105
106BOOST_AUTO_TEST_CASE( SamePinLayout_Compatible )
107{
108 auto base = MakeTwoPinPassive( wxS( "R_100R" ) );
109 auto candidate = MakeTwoPinPassive( wxS( "R_1K" ) );
110
111 auto results = ValidateVariantSymbolCompatibility( *base, *candidate );
112
113 BOOST_CHECK( results.empty() );
114}
115
116
117BOOST_AUTO_TEST_CASE( SamePinLayout_DifferentFootprint_Compatible )
118{
119 auto base = MakeTwoPinPassive( wxS( "R_100R" ) );
120 base->GetFootprintField().SetText( wxS( "R_0402" ) );
121
122 auto candidate = MakeTwoPinPassive( wxS( "R_10K" ) );
123 candidate->GetFootprintField().SetText( wxS( "R_0603" ) );
124
125 auto results = ValidateVariantSymbolCompatibility( *base, *candidate );
126
127 BOOST_CHECK( results.empty() );
128}
129
130
131BOOST_AUTO_TEST_CASE( CandidateHasExtraPins_Incompatible )
132{
133 auto base = MakeTwoPinPassive( wxS( "R_100R" ) );
134
135 auto candidate = std::make_unique<LIB_SYMBOL>( wxS( "R_3PIN" ) );
136 AddPin( *candidate, wxS( "1" ), VECTOR2I( 0, 0 ) );
137 AddPin( *candidate, wxS( "2" ), VECTOR2I( 0, 5080000 ) );
138 AddPin( *candidate, wxS( "3" ), VECTOR2I( 2540000, 2540000 ) );
139
140 auto results = ValidateVariantSymbolCompatibility( *base, *candidate );
141
142 BOOST_CHECK( !results.empty() );
143}
144
145
146BOOST_AUTO_TEST_CASE( DuplicatePinNumbersAtMatchingPositions_Compatible )
147{
148 LIB_SYMBOL base( wxS( "STACKED_BASE" ) );
149 AddPin( base, wxS( "1" ), VECTOR2I( 0, 0 ) );
150 AddPin( base, wxS( "1" ), VECTOR2I( 0, 2540000 ) );
151
152 LIB_SYMBOL candidate( wxS( "STACKED_CANDIDATE" ) );
153 AddPin( candidate, wxS( "1" ), VECTOR2I( 0, 2540000 ) );
154 AddPin( candidate, wxS( "1" ), VECTOR2I( 0, 0 ) );
155
156 BOOST_CHECK( ValidateVariantSymbolCompatibility( base, candidate ).empty() );
157}
158
159
160BOOST_AUTO_TEST_CASE( DuplicatePinNumbersMissingOccurrence_Incompatible )
161{
162 LIB_SYMBOL base( wxS( "STACKED_BASE" ) );
163 AddPin( base, wxS( "1" ), VECTOR2I( 0, 0 ) );
164 AddPin( base, wxS( "1" ), VECTOR2I( 0, 2540000 ) );
165
166 LIB_SYMBOL candidate( wxS( "STACKED_CANDIDATE" ) );
167 AddPin( candidate, wxS( "1" ), VECTOR2I( 0, 0 ) );
168
169 BOOST_CHECK( !ValidateVariantSymbolCompatibility( base, candidate ).empty() );
170}
171
172
173BOOST_AUTO_TEST_CASE( DuplicatePinNumbersMapByPosition )
174{
175 LIB_SYMBOL base( wxS( "STACKED_BASE" ) );
176 AddPin( base, wxS( "1" ), VECTOR2I( 0, 0 ) );
177 AddPin( base, wxS( "1" ), VECTOR2I( 0, 2540000 ) );
178
180 SCH_SYMBOL symbol( base, base.GetLibId(), &path, 1 );
181
182 LIB_SYMBOL candidate( wxS( "STACKED_CANDIDATE" ) );
183 AddPin( candidate, wxS( "1" ), VECTOR2I( 0, 2540000 ) );
184 AddPin( candidate, wxS( "1" ), VECTOR2I( 0, 0 ) );
185
186 const LIB_SYMBOL& constCandidate = candidate;
187 std::vector<const SCH_PIN*> candidatePins = constCandidate.GetGraphicalPins( 1, 1 );
188 std::vector<SCH_PIN*> mapped = symbol.MapLibPins( candidatePins, true );
189
190 BOOST_REQUIRE_EQUAL( mapped.size(), 2 );
191 BOOST_REQUIRE( mapped[0] );
192 BOOST_REQUIRE( mapped[1] );
193 BOOST_CHECK_NE( mapped[0], mapped[1] );
194 BOOST_CHECK_EQUAL( mapped[0]->GetLibPin()->GetPosition(), candidatePins[0]->GetPosition() );
195 BOOST_CHECK_EQUAL( mapped[1]->GetLibPin()->GetPosition(), candidatePins[1]->GetPosition() );
196}
197
198
199BOOST_AUTO_TEST_CASE( CandidateMissingPin_Incompatible )
200{
201 auto base = std::make_unique<LIB_SYMBOL>( wxS( "R_3PIN" ) );
202 AddPin( *base, wxS( "1" ), VECTOR2I( 0, 0 ) );
203 AddPin( *base, wxS( "2" ), VECTOR2I( 0, 5080000 ) );
204 AddPin( *base, wxS( "3" ), VECTOR2I( 2540000, 2540000 ) );
205
206 auto candidate = MakeTwoPinPassive( wxS( "R_100R" ) );
207
208 auto results = ValidateVariantSymbolCompatibility( *base, *candidate );
209
210 BOOST_CHECK( !results.empty() );
211 BOOST_CHECK( HasErrorForPin( results, VARIANT_COMPAT_ERROR::MISSING_PIN_NUMBER, wxS( "3" ) ) );
212}
213
214
215BOOST_AUTO_TEST_CASE( PinPositionMismatch_Incompatible )
216{
217 auto base = MakeTwoPinPassive( wxS( "R_100R" ) );
218
219 auto candidate = std::make_unique<LIB_SYMBOL>( wxS( "R_WRONG_POS" ) );
220 AddPin( *candidate, wxS( "1" ), VECTOR2I( 0, 0 ) );
221 AddPin( *candidate, wxS( "2" ), VECTOR2I( 0, 7620000 ) );
222
223 auto results = ValidateVariantSymbolCompatibility( *base, *candidate );
224
225 BOOST_CHECK( !results.empty() );
226 BOOST_CHECK( HasErrorForPin( results, VARIANT_COMPAT_ERROR::PIN_POSITION_MISMATCH,
227 wxS( "2" ) ) );
228}
229
230
231BOOST_AUTO_TEST_CASE( PinTypeMismatch_Incompatible )
232{
233 auto base = MakeTwoPinPassive( wxS( "R_100R" ) );
234
235 auto candidate = std::make_unique<LIB_SYMBOL>( wxS( "R_WRONG_TYPE" ) );
236 AddPin( *candidate, wxS( "1" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT );
237 AddPin( *candidate, wxS( "2" ), VECTOR2I( 0, 5080000 ) );
238
239 auto results = ValidateVariantSymbolCompatibility( *base, *candidate );
240
241 BOOST_CHECK( !results.empty() );
242 BOOST_CHECK( HasErrorForPin( results, VARIANT_COMPAT_ERROR::PIN_TYPE_MISMATCH,
243 wxS( "1" ) ) );
244}
245
246
247BOOST_AUTO_TEST_CASE( DifferentSymbolType_Incompatible )
248{
249 auto base = MakeTwoPinPassive( wxS( "R_100R" ) );
250
251 auto candidate = std::make_unique<LIB_SYMBOL>( wxS( "C_100nF" ) );
252 AddPin( *candidate, wxS( "1" ), VECTOR2I( 0, 2540000 ) );
253 AddPin( *candidate, wxS( "2" ), VECTOR2I( 0, -2540000 ) );
254
255 auto results = ValidateVariantSymbolCompatibility( *base, *candidate );
256
257 BOOST_CHECK( !results.empty() );
258 BOOST_CHECK( HasError( results, VARIANT_COMPAT_ERROR::PIN_POSITION_MISMATCH ) );
259}
260
261
262BOOST_AUTO_TEST_CASE( MultiUnit_AllUnitsMatch_Compatible )
263{
264 auto base = std::make_unique<LIB_SYMBOL>( wxS( "DUAL_OPAMP_BASE" ) );
265 base->SetUnitCount( 2, false );
266 AddPin( *base, wxS( "1" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 1 );
267 AddPin( *base, wxS( "2" ), VECTOR2I( 0, 2540000 ), ELECTRICAL_PINTYPE::PT_INPUT, 1 );
268 AddPin( *base, wxS( "3" ), VECTOR2I( 5080000, 1270000 ), ELECTRICAL_PINTYPE::PT_OUTPUT, 1 );
269 AddPin( *base, wxS( "5" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 2 );
270 AddPin( *base, wxS( "6" ), VECTOR2I( 0, 2540000 ), ELECTRICAL_PINTYPE::PT_INPUT, 2 );
271 AddPin( *base, wxS( "7" ), VECTOR2I( 5080000, 1270000 ), ELECTRICAL_PINTYPE::PT_OUTPUT, 2 );
272
273 auto candidate = std::make_unique<LIB_SYMBOL>( wxS( "DUAL_OPAMP_CAND" ) );
274 candidate->SetUnitCount( 2, false );
275 AddPin( *candidate, wxS( "1" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 1 );
276 AddPin( *candidate, wxS( "2" ), VECTOR2I( 0, 2540000 ), ELECTRICAL_PINTYPE::PT_INPUT, 1 );
277 AddPin( *candidate, wxS( "3" ), VECTOR2I( 5080000, 1270000 ), ELECTRICAL_PINTYPE::PT_OUTPUT, 1 );
278 AddPin( *candidate, wxS( "5" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 2 );
279 AddPin( *candidate, wxS( "6" ), VECTOR2I( 0, 2540000 ), ELECTRICAL_PINTYPE::PT_INPUT, 2 );
280 AddPin( *candidate, wxS( "7" ), VECTOR2I( 5080000, 1270000 ), ELECTRICAL_PINTYPE::PT_OUTPUT, 2 );
281
282 auto results = ValidateVariantSymbolCompatibility( *base, *candidate );
283
284 BOOST_CHECK( results.empty() );
285}
286
287
288BOOST_AUTO_TEST_CASE( MultiUnit_OneUnitMismatch_Incompatible )
289{
290 auto base = std::make_unique<LIB_SYMBOL>( wxS( "DUAL_OPAMP_BASE" ) );
291 base->SetUnitCount( 2, false );
292 AddPin( *base, wxS( "1" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 1 );
293 AddPin( *base, wxS( "2" ), VECTOR2I( 0, 2540000 ), ELECTRICAL_PINTYPE::PT_INPUT, 1 );
294 AddPin( *base, wxS( "3" ), VECTOR2I( 5080000, 1270000 ), ELECTRICAL_PINTYPE::PT_OUTPUT, 1 );
295 AddPin( *base, wxS( "5" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 2 );
296 AddPin( *base, wxS( "6" ), VECTOR2I( 0, 2540000 ), ELECTRICAL_PINTYPE::PT_INPUT, 2 );
297 AddPin( *base, wxS( "7" ), VECTOR2I( 5080000, 1270000 ), ELECTRICAL_PINTYPE::PT_OUTPUT, 2 );
298
299 auto candidate = std::make_unique<LIB_SYMBOL>( wxS( "DUAL_OPAMP_CAND" ) );
300 candidate->SetUnitCount( 2, false );
301 AddPin( *candidate, wxS( "1" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 1 );
302 AddPin( *candidate, wxS( "2" ), VECTOR2I( 0, 2540000 ), ELECTRICAL_PINTYPE::PT_INPUT, 1 );
303 AddPin( *candidate, wxS( "3" ), VECTOR2I( 5080000, 1270000 ), ELECTRICAL_PINTYPE::PT_OUTPUT, 1 );
304 // Unit 2 is missing pin "7"
305 AddPin( *candidate, wxS( "5" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 2 );
306 AddPin( *candidate, wxS( "6" ), VECTOR2I( 0, 2540000 ), ELECTRICAL_PINTYPE::PT_INPUT, 2 );
307
308 auto results = ValidateVariantSymbolCompatibility( *base, *candidate );
309
310 BOOST_CHECK( !results.empty() );
311 BOOST_CHECK( HasErrorForPin( results, VARIANT_COMPAT_ERROR::MISSING_PIN_NUMBER, wxS( "7" ) ) );
312}
313
314
315BOOST_AUTO_TEST_CASE( CandidateFewerUnits_Incompatible )
316{
317 auto base = std::make_unique<LIB_SYMBOL>( wxS( "QUAD_OPAMP" ) );
318 base->SetUnitCount( 4, false );
319 AddPin( *base, wxS( "1" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 1 );
320 AddPin( *base, wxS( "2" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 2 );
321 AddPin( *base, wxS( "3" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 3 );
322 AddPin( *base, wxS( "4" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 4 );
323
324 auto candidate = std::make_unique<LIB_SYMBOL>( wxS( "DUAL_OPAMP" ) );
325 candidate->SetUnitCount( 2, false );
326 AddPin( *candidate, wxS( "1" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 1 );
327 AddPin( *candidate, wxS( "2" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 2 );
328
329 auto results = ValidateVariantSymbolCompatibility( *base, *candidate );
330
331 BOOST_CHECK( !results.empty() );
332 BOOST_CHECK( HasError( results, VARIANT_COMPAT_ERROR::INSUFFICIENT_UNITS ) );
333}
334
335
336BOOST_AUTO_TEST_CASE( CandidateMoreUnits_Incompatible )
337{
338 auto base = std::make_unique<LIB_SYMBOL>( wxS( "DUAL_OPAMP" ) );
339 base->SetUnitCount( 2, false );
340 AddPin( *base, wxS( "1" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 1 );
341 AddPin( *base, wxS( "2" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 2 );
342
343 auto candidate = std::make_unique<LIB_SYMBOL>( wxS( "QUAD_OPAMP" ) );
344 candidate->SetUnitCount( 4, false );
345 AddPin( *candidate, wxS( "1" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 1 );
346 AddPin( *candidate, wxS( "2" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 2 );
347 AddPin( *candidate, wxS( "3" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 3 );
348 AddPin( *candidate, wxS( "4" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 4 );
349
350 auto results = ValidateVariantSymbolCompatibility( *base, *candidate );
351
352 BOOST_CHECK( !results.empty() );
353}
354
355
356BOOST_AUTO_TEST_CASE( BodyStyle_BothHave_Compatible )
357{
358 auto base = std::make_unique<LIB_SYMBOL>( wxS( "GATE_BASE" ) );
359 base->SetHasDeMorganBodyStyles( true );
360 AddPin( *base, wxS( "1" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 1, 1 );
361 AddPin( *base, wxS( "2" ), VECTOR2I( 0, 2540000 ), ELECTRICAL_PINTYPE::PT_OUTPUT, 1, 1 );
362 AddPin( *base, wxS( "1" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 1, 2 );
363 AddPin( *base, wxS( "2" ), VECTOR2I( 0, 2540000 ), ELECTRICAL_PINTYPE::PT_OUTPUT, 1, 2 );
364
365 auto candidate = std::make_unique<LIB_SYMBOL>( wxS( "GATE_CAND" ) );
366 candidate->SetHasDeMorganBodyStyles( true );
367 AddPin( *candidate, wxS( "1" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 1, 1 );
368 AddPin( *candidate, wxS( "2" ), VECTOR2I( 0, 2540000 ), ELECTRICAL_PINTYPE::PT_OUTPUT, 1, 1 );
369 AddPin( *candidate, wxS( "1" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 1, 2 );
370 AddPin( *candidate, wxS( "2" ), VECTOR2I( 0, 2540000 ), ELECTRICAL_PINTYPE::PT_OUTPUT, 1, 2 );
371
372 auto results = ValidateVariantSymbolCompatibility( *base, *candidate );
373
374 BOOST_CHECK( results.empty() );
375}
376
377
378BOOST_AUTO_TEST_CASE( BodyStyle_CandidateMissing_Incompatible )
379{
380 auto base = std::make_unique<LIB_SYMBOL>( wxS( "GATE_BASE" ) );
381 base->SetHasDeMorganBodyStyles( true );
382 AddPin( *base, wxS( "1" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 1, 1 );
383 AddPin( *base, wxS( "2" ), VECTOR2I( 0, 2540000 ), ELECTRICAL_PINTYPE::PT_OUTPUT, 1, 1 );
384 AddPin( *base, wxS( "1" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 1, 2 );
385 AddPin( *base, wxS( "2" ), VECTOR2I( 0, 2540000 ), ELECTRICAL_PINTYPE::PT_OUTPUT, 1, 2 );
386
387 auto candidate = std::make_unique<LIB_SYMBOL>( wxS( "GATE_CAND" ) );
388 AddPin( *candidate, wxS( "1" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_INPUT, 1, 1 );
389 AddPin( *candidate, wxS( "2" ), VECTOR2I( 0, 2540000 ), ELECTRICAL_PINTYPE::PT_OUTPUT, 1, 1 );
390
391 auto results = ValidateVariantSymbolCompatibility( *base, *candidate );
392
393 BOOST_CHECK( !results.empty() );
394 BOOST_CHECK( HasError( results, VARIANT_COMPAT_ERROR::MISSING_BODY_STYLE ) );
395}
396
397
398BOOST_AUTO_TEST_CASE( EmptySymbols_Compatible )
399{
400 LIB_SYMBOL base( wxS( "EMPTY_A" ) );
401 LIB_SYMBOL candidate( wxS( "EMPTY_B" ) );
402
403 auto results = ValidateVariantSymbolCompatibility( base, candidate );
404
405 BOOST_CHECK( results.empty() );
406}
407
408
409BOOST_AUTO_TEST_CASE( MultipleErrors_AllReported )
410{
411 auto base = std::make_unique<LIB_SYMBOL>( wxS( "BASE" ) );
412 AddPin( *base, wxS( "1" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_PASSIVE );
413 AddPin( *base, wxS( "2" ), VECTOR2I( 0, 5080000 ), ELECTRICAL_PINTYPE::PT_PASSIVE );
414 AddPin( *base, wxS( "3" ), VECTOR2I( 2540000, 0 ), ELECTRICAL_PINTYPE::PT_INPUT );
415
416 auto candidate = std::make_unique<LIB_SYMBOL>( wxS( "CAND" ) );
417 // Pin 1 has wrong type
418 AddPin( *candidate, wxS( "1" ), VECTOR2I( 0, 0 ), ELECTRICAL_PINTYPE::PT_OUTPUT );
419 // Pin 2 has wrong position
420 AddPin( *candidate, wxS( "2" ), VECTOR2I( 0, 7620000 ), ELECTRICAL_PINTYPE::PT_PASSIVE );
421 // Pin 3 is missing
422
423 auto results = ValidateVariantSymbolCompatibility( *base, *candidate );
424
425 BOOST_CHECK_EQUAL( results.size(), 3 );
426 BOOST_CHECK( HasErrorForPin( results, VARIANT_COMPAT_ERROR::PIN_TYPE_MISMATCH, wxS( "1" ) ) );
427 BOOST_CHECK( HasErrorForPin( results, VARIANT_COMPAT_ERROR::PIN_POSITION_MISMATCH,
428 wxS( "2" ) ) );
429 BOOST_CHECK( HasErrorForPin( results, VARIANT_COMPAT_ERROR::MISSING_PIN_NUMBER, wxS( "3" ) ) );
430}
431
432
Define a library symbol object.
Definition lib_symbol.h:114
const LIB_ID & GetLibId() const override
Definition lib_symbol.h:183
std::vector< const SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Schematic symbol object.
Definition sch_symbol.h:69
std::vector< SCH_PIN * > MapLibPins(const std::vector< const SCH_PIN * > &aLibPins, bool aByNumber) const
Map pins of an effective library symbol to this symbol's instance pins.
static bool empty(const wxTextEntryBase *aCtrl)
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
Definition pin_type.h:32
@ PT_INPUT
usual pin input: must be connected
Definition pin_type.h:33
@ PT_OUTPUT
usual output
Definition pin_type.h:34
@ PT_PASSIVE
pin for passive symbols: must be connected, and can be connected to any pin.
Definition pin_type.h:39
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
std::string path
KIBIS_PIN * pin
BOOST_CHECK_EQUAL(result, "25.4")
BOOST_AUTO_TEST_CASE(IdenticalSymbols_Compatible)
std::vector< VARIANT_COMPAT_RESULT > ValidateVariantSymbolCompatibility(const LIB_SYMBOL &aBase, const LIB_SYMBOL &aCandidate)
Check whether aCandidate can be used as a variant symbol override for aBase.
VARIANT_COMPAT_ERROR
Describes a single pin compatibility problem found when comparing a candidate symbol against a base s...
@ PIN_POSITION_MISMATCH
A matching pin number has a different position in library coordinates.
@ PIN_TYPE_MISMATCH
A matching pin number has a different electrical type.
@ MISSING_BODY_STYLE
Base uses alternate body styles but candidate does not.
@ MISSING_PIN_NUMBER
A base pin number is absent from the candidate for a given unit/body style.
@ INSUFFICIENT_UNITS
Candidate has fewer units than the base.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683