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(
"R_100R" ) );
98 auto candidate = MakeTwoPinPassive( wxS(
"R_100R" ) );
102 BOOST_CHECK( results.empty() );
108 auto base = MakeTwoPinPassive( wxS(
"R_100R" ) );
109 auto candidate = MakeTwoPinPassive( wxS(
"R_1K" ) );
113 BOOST_CHECK( results.empty() );
119 auto base = MakeTwoPinPassive( wxS(
"R_100R" ) );
120 base->GetFootprintField().SetText( wxS(
"R_0402" ) );
122 auto candidate = MakeTwoPinPassive( wxS(
"R_10K" ) );
123 candidate->GetFootprintField().SetText( wxS(
"R_0603" ) );
127 BOOST_CHECK( results.empty() );
133 auto base = MakeTwoPinPassive( wxS(
"R_100R" ) );
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 ) );
142 BOOST_CHECK( !results.empty() );
149 AddPin( base, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
150 AddPin( base, wxS(
"1" ),
VECTOR2I( 0, 2540000 ) );
152 LIB_SYMBOL candidate( wxS(
"STACKED_CANDIDATE" ) );
153 AddPin( candidate, wxS(
"1" ),
VECTOR2I( 0, 2540000 ) );
154 AddPin( candidate, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
163 AddPin( base, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
164 AddPin( base, wxS(
"1" ),
VECTOR2I( 0, 2540000 ) );
166 LIB_SYMBOL candidate( wxS(
"STACKED_CANDIDATE" ) );
167 AddPin( candidate, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
176 AddPin( base, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
177 AddPin( base, wxS(
"1" ),
VECTOR2I( 0, 2540000 ) );
182 LIB_SYMBOL candidate( wxS(
"STACKED_CANDIDATE" ) );
183 AddPin( candidate, wxS(
"1" ),
VECTOR2I( 0, 2540000 ) );
184 AddPin( candidate, wxS(
"1" ),
VECTOR2I( 0, 0 ) );
187 std::vector<const SCH_PIN*> candidatePins = constCandidate.
GetGraphicalPins( 1, 1 );
188 std::vector<SCH_PIN*> mapped = symbol.
MapLibPins( candidatePins,
true );
190 BOOST_REQUIRE_EQUAL( mapped.size(), 2 );
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() );
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 ) );
206 auto candidate = MakeTwoPinPassive( wxS(
"R_100R" ) );
210 BOOST_CHECK( !results.empty() );
217 auto base = MakeTwoPinPassive( wxS(
"R_100R" ) );
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 ) );
225 BOOST_CHECK( !results.empty() );
233 auto base = MakeTwoPinPassive( wxS(
"R_100R" ) );
235 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"R_WRONG_TYPE" ) );
237 AddPin( *candidate, wxS(
"2" ),
VECTOR2I( 0, 5080000 ) );
241 BOOST_CHECK( !results.empty() );
249 auto base = MakeTwoPinPassive( wxS(
"R_100R" ) );
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 ) );
257 BOOST_CHECK( !results.empty() );
264 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"DUAL_OPAMP_BASE" ) );
265 base->SetUnitCount( 2,
false );
273 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"DUAL_OPAMP_CAND" ) );
274 candidate->SetUnitCount( 2,
false );
284 BOOST_CHECK( results.empty() );
290 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"DUAL_OPAMP_BASE" ) );
291 base->SetUnitCount( 2,
false );
299 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"DUAL_OPAMP_CAND" ) );
300 candidate->SetUnitCount( 2,
false );
310 BOOST_CHECK( !results.empty() );
317 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"QUAD_OPAMP" ) );
318 base->SetUnitCount( 4,
false );
324 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"DUAL_OPAMP" ) );
325 candidate->SetUnitCount( 2,
false );
331 BOOST_CHECK( !results.empty() );
338 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"DUAL_OPAMP" ) );
339 base->SetUnitCount( 2,
false );
343 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"QUAD_OPAMP" ) );
344 candidate->SetUnitCount( 4,
false );
352 BOOST_CHECK( !results.empty() );
358 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"GATE_BASE" ) );
359 base->SetHasDeMorganBodyStyles(
true );
365 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"GATE_CAND" ) );
366 candidate->SetHasDeMorganBodyStyles(
true );
374 BOOST_CHECK( results.empty() );
380 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"GATE_BASE" ) );
381 base->SetHasDeMorganBodyStyles(
true );
387 auto candidate = std::make_unique<LIB_SYMBOL>( wxS(
"GATE_CAND" ) );
393 BOOST_CHECK( !results.empty() );
405 BOOST_CHECK( results.empty() );
411 auto base = std::make_unique<LIB_SYMBOL>( wxS(
"BASE" ) );
416 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_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(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