41 int aUnit = 1,
int aBodyStyle = 1 )
44 pin->SetNumber( aNumber );
45 pin->SetPosition( aPos );
46 pin->SetType( aType );
47 pin->SetUnit( aUnit );
48 pin->SetBodyStyle( aBodyStyle );
56std::unique_ptr<LIB_SYMBOL> MakeTwoPinPassive(
const wxString& aName )
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 ) );
69 if( r.error == aError )
77bool HasErrorForPin(
const std::vector<VARIANT_COMPAT_RESULT>& aResults,
82 if( r.error == aError && r.pinNumber == aPin )
97 auto base = MakeTwoPinPassive( wxS(
"Base" ) );
98 auto candidate = MakeTwoPinPassive( wxS(
"Candidate" ) );
107 auto base = MakeTwoPinPassive( wxS(
"R_100R" ) );
108 auto candidate = MakeTwoPinPassive( wxS(
"R_100R" ) );
112 BOOST_CHECK( results.empty() );
118 auto base = MakeTwoPinPassive( wxS(
"R_100R" ) );
119 auto candidate = MakeTwoPinPassive( wxS(
"R_1K" ) );
123 BOOST_CHECK( results.empty() );
129 auto base = MakeTwoPinPassive( wxS(
"R_100R" ) );
130 base->GetFootprintField().SetText( wxS(
"R_0402" ) );
132 auto candidate = MakeTwoPinPassive( wxS(
"R_10K" ) );
133 candidate->GetFootprintField().SetText( wxS(
"R_0603" ) );
137 BOOST_CHECK( results.empty() );
143 auto base = MakeTwoPinPassive( wxS(
"R_100R" ) );
145 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"R_3PIN" ) );
146 AddPin( *candidate, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
147 AddPin( *candidate, wxS(
"2" ),
VECTOR2I( 0, 5080000 ) );
148 AddPin( *candidate, wxS(
"3" ),
VECTOR2I( 2540000, 2540000 ) );
152 BOOST_CHECK( !results.empty() );
159 AddPin( base, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
160 AddPin( base, wxS(
"1" ),
VECTOR2I( 0, 2540000 ) );
162 LIB_SYMBOL candidate( wxS(
"STACKED_CANDIDATE" ) );
163 AddPin( candidate, wxS(
"1" ),
VECTOR2I( 0, 2540000 ) );
164 AddPin( candidate, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
173 AddPin( base, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
174 AddPin( base, wxS(
"1" ),
VECTOR2I( 0, 2540000 ) );
176 LIB_SYMBOL candidate( wxS(
"STACKED_CANDIDATE" ) );
177 AddPin( candidate, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
186 AddPin( base, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
187 AddPin( base, wxS(
"1" ),
VECTOR2I( 0, 2540000 ) );
192 LIB_SYMBOL candidate( wxS(
"STACKED_CANDIDATE" ) );
193 AddPin( candidate, wxS(
"1" ),
VECTOR2I( 0, 2540000 ) );
194 AddPin( candidate, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
197 std::vector<const SCH_PIN*> candidatePins = constCandidate.
GetGraphicalPins( 1, 1 );
198 std::vector<SCH_PIN*> mapped = symbol.
MapLibPins( candidatePins,
true );
200 BOOST_REQUIRE_EQUAL( mapped.size(), 2 );
203 BOOST_CHECK_NE( mapped[0], mapped[1] );
204 BOOST_CHECK_EQUAL( mapped[0]->GetLibPin()->GetPosition(), candidatePins[0]->GetPosition() );
205 BOOST_CHECK_EQUAL( mapped[1]->GetLibPin()->GetPosition(), candidatePins[1]->GetPosition() );
211 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"R_3PIN" ) );
212 AddPin( *base, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
213 AddPin( *base, wxS(
"2" ),
VECTOR2I( 0, 5080000 ) );
214 AddPin( *base, wxS(
"3" ),
VECTOR2I( 2540000, 2540000 ) );
216 auto candidate = MakeTwoPinPassive( wxS(
"R_100R" ) );
220 BOOST_CHECK( !results.empty() );
227 auto base = MakeTwoPinPassive( wxS(
"R_100R" ) );
229 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"R_WRONG_POS" ) );
230 AddPin( *candidate, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
231 AddPin( *candidate, wxS(
"2" ),
VECTOR2I( 0, 7620000 ) );
235 BOOST_CHECK( !results.empty() );
243 auto base = MakeTwoPinPassive( wxS(
"R_100R" ) );
245 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"R_WRONG_TYPE" ) );
247 AddPin( *candidate, wxS(
"2" ),
VECTOR2I( 0, 5080000 ) );
251 BOOST_CHECK( !results.empty() );
259 auto base = MakeTwoPinPassive( wxS(
"R_100R" ) );
261 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"C_100nF" ) );
262 AddPin( *candidate, wxS(
"1" ),
VECTOR2I( 0, 2540000 ) );
263 AddPin( *candidate, wxS(
"2" ),
VECTOR2I( 0, -2540000 ) );
267 BOOST_CHECK( !results.empty() );
274 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"DUAL_OPAMP_BASE" ) );
275 base->SetUnitCount( 2,
false );
283 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"DUAL_OPAMP_CAND" ) );
284 candidate->SetUnitCount( 2,
false );
294 BOOST_CHECK( results.empty() );
300 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"DUAL_OPAMP_BASE" ) );
301 base->SetUnitCount( 2,
false );
309 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"DUAL_OPAMP_CAND" ) );
310 candidate->SetUnitCount( 2,
false );
320 BOOST_CHECK( !results.empty() );
327 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"QUAD_OPAMP" ) );
328 base->SetUnitCount( 4,
false );
334 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"DUAL_OPAMP" ) );
335 candidate->SetUnitCount( 2,
false );
341 BOOST_CHECK( !results.empty() );
348 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"DUAL_OPAMP" ) );
349 base->SetUnitCount( 2,
false );
353 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"QUAD_OPAMP" ) );
354 candidate->SetUnitCount( 4,
false );
362 BOOST_CHECK( !results.empty() );
368 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"GATE_BASE" ) );
369 base->SetHasDeMorganBodyStyles(
true );
375 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"GATE_CAND" ) );
376 candidate->SetHasDeMorganBodyStyles(
true );
384 BOOST_CHECK( results.empty() );
390 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"GATE_BASE" ) );
391 base->SetHasDeMorganBodyStyles(
true );
397 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"GATE_CAND" ) );
403 BOOST_CHECK( !results.empty() );
415 BOOST_CHECK( results.empty() );
421 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"BASE" ) );
426 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"CAND" ) );
Define a library symbol object.
const LIB_ID & GetLibId() const override
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...
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.
@ 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()
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