42 int aUnit = 1,
int aBodyStyle = 1 )
45 pin->SetNumber( aNumber );
46 pin->SetPosition( aPos );
47 pin->SetType( aType );
48 pin->SetUnit( aUnit );
49 pin->SetBodyStyle( aBodyStyle );
57std::unique_ptr<LIB_SYMBOL> MakeTwoPinPassive(
const wxString& aName )
59 auto sym = std::make_unique<LIB_SYMBOL>( aName );
60 AddPin( *sym, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
61 AddPin( *sym, wxS(
"2" ),
VECTOR2I( 0, 5080000 ) );
66std::vector<VARIANT_COMPAT_RESULT> CheckCompatibility(
const LIB_SYMBOL& aBase,
const LIB_SYMBOL& aCandidate )
73 for(
size_t i = 0; i <
expected.size(); ++i )
90 if( r.error == aError )
98bool HasErrorForPin(
const std::vector<VARIANT_COMPAT_RESULT>& aResults,
VARIANT_COMPAT_ERROR aError,
99 const wxString& aPin )
103 if( r.error == aError && r.pinNumber == aPin )
118 auto base = MakeTwoPinPassive( wxS(
"Base" ) );
119 auto candidate = MakeTwoPinPassive( wxS(
"Candidate" ) );
122 BOOST_CHECK( CheckCompatibility( *base, *candidate ).
empty() );
128 auto base = MakeTwoPinPassive( wxS(
"R_100R" ) );
129 auto candidate = MakeTwoPinPassive( wxS(
"R_100R" ) );
131 auto results = CheckCompatibility( *base, *candidate );
133 BOOST_CHECK( results.empty() );
139 auto base = MakeTwoPinPassive( wxS(
"R_100R" ) );
140 auto candidate = MakeTwoPinPassive( wxS(
"R_1K" ) );
142 auto results = CheckCompatibility( *base, *candidate );
144 BOOST_CHECK( results.empty() );
150 auto base = MakeTwoPinPassive( wxS(
"R_100R" ) );
151 base->GetFootprintField().SetText( wxS(
"R_0402" ) );
153 auto candidate = MakeTwoPinPassive( wxS(
"R_10K" ) );
154 candidate->GetFootprintField().SetText( wxS(
"R_0603" ) );
156 auto results = CheckCompatibility( *base, *candidate );
158 BOOST_CHECK( results.empty() );
164 auto base = MakeTwoPinPassive( wxS(
"R_100R" ) );
166 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"R_3PIN" ) );
167 AddPin( *candidate, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
168 AddPin( *candidate, wxS(
"2" ),
VECTOR2I( 0, 5080000 ) );
169 AddPin( *candidate, wxS(
"3" ),
VECTOR2I( 2540000, 2540000 ) );
171 auto results = CheckCompatibility( *base, *candidate );
173 BOOST_CHECK( !results.empty() );
180 AddPin( base, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
181 AddPin( base, wxS(
"1" ),
VECTOR2I( 0, 2540000 ) );
183 LIB_SYMBOL candidate( wxS(
"STACKED_CANDIDATE" ) );
184 AddPin( candidate, wxS(
"1" ),
VECTOR2I( 0, 2540000 ) );
185 AddPin( candidate, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
187 BOOST_CHECK( CheckCompatibility( base, candidate ).
empty() );
194 AddPin( base, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
195 AddPin( base, wxS(
"1" ),
VECTOR2I( 0, 2540000 ) );
197 LIB_SYMBOL candidate( wxS(
"STACKED_CANDIDATE" ) );
198 AddPin( candidate, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
200 BOOST_CHECK( !CheckCompatibility( base, candidate ).
empty() );
207 AddPin( base, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
208 AddPin( base, wxS(
"1" ),
VECTOR2I( 0, 2540000 ) );
213 LIB_SYMBOL candidate( wxS(
"STACKED_CANDIDATE" ) );
214 AddPin( candidate, wxS(
"1" ),
VECTOR2I( 0, 2540000 ) );
215 AddPin( candidate, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
218 std::vector<SCH_PIN*> mapped = symbol.
MapLibPins( candidatePins,
true );
220 BOOST_REQUIRE_EQUAL( mapped.size(), 2 );
223 BOOST_CHECK_NE( mapped[0], mapped[1] );
224 BOOST_CHECK_EQUAL( mapped[0]->GetLibPin()->GetPosition(), candidatePins[0]->GetPosition() );
225 BOOST_CHECK_EQUAL( mapped[1]->GetLibPin()->GetPosition(), candidatePins[1]->GetPosition() );
231 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"R_3PIN" ) );
232 AddPin( *base, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
233 AddPin( *base, wxS(
"2" ),
VECTOR2I( 0, 5080000 ) );
234 AddPin( *base, wxS(
"3" ),
VECTOR2I( 2540000, 2540000 ) );
236 auto candidate = MakeTwoPinPassive( wxS(
"R_100R" ) );
238 auto results = CheckCompatibility( *base, *candidate );
240 BOOST_CHECK( !results.empty() );
247 auto base = MakeTwoPinPassive( wxS(
"R_100R" ) );
249 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"R_WRONG_POS" ) );
250 AddPin( *candidate, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
251 AddPin( *candidate, wxS(
"2" ),
VECTOR2I( 0, 7620000 ) );
253 auto results = CheckCompatibility( *base, *candidate );
255 BOOST_CHECK( !results.empty() );
262 auto base = MakeTwoPinPassive( wxS(
"R_100R" ) );
264 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"R_WRONG_TYPE" ) );
266 AddPin( *candidate, wxS(
"2" ),
VECTOR2I( 0, 5080000 ) );
268 auto results = CheckCompatibility( *base, *candidate );
270 BOOST_CHECK( !results.empty() );
277 auto base = MakeTwoPinPassive( wxS(
"R_100R" ) );
279 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"C_100nF" ) );
280 AddPin( *candidate, wxS(
"1" ),
VECTOR2I( 0, 2540000 ) );
281 AddPin( *candidate, wxS(
"2" ),
VECTOR2I( 0, -2540000 ) );
283 auto results = CheckCompatibility( *base, *candidate );
285 BOOST_CHECK( !results.empty() );
292 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"DUAL_OPAMP_BASE" ) );
293 base->SetUnitCount( 2,
false );
301 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"DUAL_OPAMP_CAND" ) );
302 candidate->SetUnitCount( 2,
false );
310 auto results = CheckCompatibility( *base, *candidate );
312 BOOST_CHECK( results.empty() );
318 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"DUAL_OPAMP_BASE" ) );
319 base->SetUnitCount( 2,
false );
327 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"DUAL_OPAMP_CAND" ) );
328 candidate->SetUnitCount( 2,
false );
336 auto results = CheckCompatibility( *base, *candidate );
338 BOOST_CHECK( !results.empty() );
345 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"QUAD_OPAMP" ) );
346 base->SetUnitCount( 4,
false );
352 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"DUAL_OPAMP" ) );
353 candidate->SetUnitCount( 2,
false );
357 auto results = CheckCompatibility( *base, *candidate );
359 BOOST_CHECK( !results.empty() );
366 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"DUAL_OPAMP" ) );
367 base->SetUnitCount( 2,
false );
371 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"QUAD_OPAMP" ) );
372 candidate->SetUnitCount( 4,
false );
378 auto results = CheckCompatibility( *base, *candidate );
380 BOOST_CHECK( !results.empty() );
386 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"GATE_BASE" ) );
387 base->SetHasDeMorganBodyStyles(
true );
393 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"GATE_CAND" ) );
394 candidate->SetHasDeMorganBodyStyles(
true );
400 auto results = CheckCompatibility( *base, *candidate );
402 BOOST_CHECK( results.empty() );
408 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"GATE_BASE" ) );
409 base->SetHasDeMorganBodyStyles(
true );
415 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"GATE_CAND" ) );
419 auto results = CheckCompatibility( *base, *candidate );
421 BOOST_CHECK( !results.empty() );
431 auto results = CheckCompatibility( base, candidate );
433 BOOST_CHECK( results.empty() );
439 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"BASE" ) );
444 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"CAND" ) );
451 auto results = CheckCompatibility( *base, *candidate );
Define a library symbol object.
const LIB_ID & GetLibId() const override
std::vector< SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const override
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...
std::vector< SCH_PIN * > MapLibPins(const std::vector< 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)
LIBRARY_SYMBOL_FACT ExtractLibrarySymbolFact(const LIB_SYMBOL &aSymbol)
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
@ PT_INPUT
usual pin input: must be connected
@ PT_UNSPECIFIED
unknown electrical properties: creates always a warning when connected
@ PT_PASSIVE
pin for passive symbols: must be connected, and can be connected to any pin.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
VECTOR3I expected(15, 30, 45)
BOOST_CHECK_EQUAL(result, "25.4")
BOOST_AUTO_TEST_CASE(UnresolvedLibraryPinTypeIsUnspecified)
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