98 std::vector<SCH_FIELD> fields;
99 m_part_no_data.CopyFields( fields );
111 ( m_part_no_data.GetValueField() )(
"Value" )( (
int)
FIELD_T::VALUE ) );
126 std::vector<SCH_FIELD> fields;
127 m_part_no_data.CopyFields( fields );
130 const std::string newFieldName =
"new_field";
131 wxString nonConstNewFieldName = newFieldName;
135 m_part_no_data.SetFields( fields );
141 BOOST_REQUIRE_EQUAL( fields.size(), 6 );
145 SCH_FIELD* gotNewField = m_part_no_data.GetField( newFieldName );
147 BOOST_REQUIRE_NE( gotNewField,
nullptr );
173 const std::vector<TEST_LIB_SYMBOL_SUBREF_CASE> cases = {
341 for(
const auto& c : cases )
344 "Subref: " << c.m_index <<
", " << c.m_addSep <<
" -> '" << c.m_expSubRef <<
"'" )
368 testPart.
SetName(
"tart_name" );
369 BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
370 testPart.
SetName(
"cart_name" );
371 BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
372 testPart.
SetName(
"part_name" );
378 BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
379 id.SetLibItemName(
"cart_name" );
381 BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
382 id.SetLibItemName(
"part_name" );
387 BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
389 m_part_no_data.SetUnitCount( 2 );
390 BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
391 m_part_no_data.SetUnitCount( 1 );
395 BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
397 m_part_no_data.SetGlobalPower();
398 BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
399 m_part_no_data.SetNormal();
405 m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[
SCH_SHAPE_T].front() );
410 m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[
SCH_SHAPE_T].front() );
416 m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[
SCH_SHAPE_T].front() );
418 m_part_no_data.AddDrawItem(
new SCH_PIN( &m_part_no_data ) );
420 m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[
SCH_PIN_T].front() );
423 wxArrayString footPrintFilters;
424 BOOST_CHECK( m_part_no_data.GetFPFilters() == footPrintFilters );
425 footPrintFilters.Add(
"b" );
428 m_part_no_data.SetFPFilters( footPrintFilters );
429 footPrintFilters.Clear();
432 footPrintFilters.Clear();
433 m_part_no_data.SetFPFilters( footPrintFilters );
437 m_part_no_data.SetDescription(
"b" );
440 m_part_no_data.SetDescription(
"a" );
442 m_part_no_data.SetDescription(
"c" );
444 m_part_no_data.SetDescription( wxEmptyString );
448 m_part_no_data.SetKeyWords(
"b" );
451 m_part_no_data.SetKeyWords(
"a" );
453 m_part_no_data.SetKeyWords(
"c" );
455 m_part_no_data.SetKeyWords( wxEmptyString );
469 m_part_no_data.LockUnits(
true );
471 m_part_no_data.LockUnits(
false );
477 m_part_no_data.SetExcludedFromBOM(
true );
479 m_part_no_data.SetExcludedFromBOM(
false );
485 m_part_no_data.SetExcludedFromBoard(
true );
487 m_part_no_data.SetExcludedFromBoard(
false );
490 m_part_no_data.SetShowPinNames(
false );
492 m_part_no_data.SetShowPinNames(
true );
498 m_part_no_data.SetShowPinNumbers(
false );
500 m_part_no_data.SetShowPinNumbers(
true );
519 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, 1 ).size() == 0 );
523 m_part_no_data.AddDrawItem( pin1 );
524 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 0, 0 ).size() == 1 );
528 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, 0 ).size() == 1 );
532 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, 1 ).size() == 1 );
537 m_part_no_data.SetUnitCount( 2 );
541 m_part_no_data.AddDrawItem( pin2 );
542 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 2, 2 ).size() == 1 );
546 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, 1 ).size() == 0 );
547 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 2, 1 ).size() == 1 );
549 m_part_no_data.RemoveDrawItem( pin2 );
550 m_part_no_data.RemoveDrawItem( pin1 );
551 m_part_no_data.RemoveDrawItem( &*m_part_no_data.GetDrawItems().begin() );
561 BOOST_CHECK( m_part_no_data.GetUnitDrawItems().size() == 0 );
566 m_part_no_data.AddDrawItem( pin1 );
567 std::vector<struct LIB_SYMBOL_UNIT> units = m_part_no_data.GetUnitDrawItems();
568 BOOST_CHECK( units.size() == 1 );
569 BOOST_CHECK( units[0].m_unit == 0 );
570 BOOST_CHECK( units[0].m_bodyStyle == 0 );
571 BOOST_CHECK( units[0].m_items[0] == pin1 );
580 std::unique_ptr<LIB_SYMBOL> parent = std::make_unique<LIB_SYMBOL>(
"parent" );
581 BOOST_CHECK( parent->IsRoot() );
584 std::unique_ptr<LIB_SYMBOL> ref = std::make_unique<LIB_SYMBOL>( *parent );
586 std::unique_ptr<LIB_SYMBOL> child = std::make_unique<LIB_SYMBOL>(
"child", parent.get() );
587 BOOST_CHECK( child->IsDerived() );
590 std::unique_ptr<LIB_SYMBOL> grandChild = std::make_unique<LIB_SYMBOL>(
"grandchild",
592 BOOST_CHECK( grandChild->IsDerived() );
595 BOOST_CHECK( parent->GetRootSymbol().get() == parent.get() );
596 BOOST_CHECK( child->GetRootSymbol().get() == parent.get() );
597 BOOST_CHECK( grandChild->GetRootSymbol().get() == parent.get() );
600 BOOST_CHECK( parentRef );
601 BOOST_CHECK( parentRef == parent->SharedPtr() );
605 BOOST_CHECK( childRef );
606 BOOST_CHECK( childRef == child->SharedPtr() );
610 parent->SetUnitCount( 4 );
612 parent->SetUnitCount( 1 );
617 BOOST_CHECK( *parent == *ref );
619 ref->SetName(
"child" );
622 child->AddField( field );
627 ref->AddField( field );
630 BOOST_CHECK( *ref == *child->Flatten() );
632 ref->SetName(
"grandchild" );
635 grandChild->AddField( field );
640 ref->AddField( field );
643 BOOST_CHECK( *ref == *grandChild->Flatten() );
646 "https://kicad/resistors.pdf" );
661 std::shared_ptr<LIB_SYMBOL>
copy = std::make_shared<LIB_SYMBOL>( m_part_no_data );
662 BOOST_CHECK( m_part_no_data == *
copy.get() );
671 std::unique_ptr<LIB_SYMBOL> symbol = std::make_unique<LIB_SYMBOL>(
"power" );
673 pin->SetNumber(
"1" );
675 pin->SetVisible(
false );
676 symbol->AddDrawItem(
pin );
678 BOOST_CHECK( !symbol->IsPower() );
679 BOOST_CHECK( symbol->IsNormal() );
681 symbol->SetGlobalPower();
682 BOOST_CHECK( symbol->IsPower() );
683 BOOST_CHECK( !symbol->IsNormal() );
virtual void SetParent(EDA_ITEM *aParent)
A logical library item identifier and consists of various portions much like a URI.
int SetLibItemName(const UTF8 &aLibItemName)
Override the library item name portion of the LIB_ID to aLibItemName.
Define a library symbol object.
const LIB_ID & GetLibId() const override
void SetUnitCount(int aCount, bool aDuplicateDrawItems=true)
Set the units per symbol count.
int Compare(const LIB_SYMBOL &aRhs, int aCompareFlags=0, REPORTER *aReporter=nullptr) const
Comparison test that can be used for operators.
static wxString LetterSubReference(int aUnit, int aFirstId)
void LockUnits(bool aLockUnits)
Set interchangeable the property for symbol units.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
void SetDescription(const wxString &aDescription)
Gets the Description field text value */.
void SetKeyWords(const wxString &aKeyWords)
void RemoveDrawItem(SCH_ITEM *aItem)
Remove draw aItem from list.
void SetFPFilters(const wxArrayString &aFilters)
void SetLibId(const LIB_ID &aLibId)
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
virtual void SetName(const wxString &aName)
void SetText(const wxString &aText) override
virtual void SetBodyStyle(int aBodyStyle)
virtual void SetUnit(int aUnit)
void SetNumber(const wxString &aNumber)
virtual void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
int GetPinNameOffset() const
virtual void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
void SetExcludedFromBOM(bool aExcludeFromBOM)
Set or clear the exclude from schematic bill of materials flag.
void SetPinNameOffset(int aOffset)
Set the offset in mils of the pin name text from the pin symbol.
void SetExcludedFromBoard(bool aExcludeFromBoard)
Set or clear exclude from board netlist flag.
TEST_LIB_SYMBOL_FIXTURE()
Part with no extra data set.
LIB_SYMBOL m_part_no_data
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
std::shared_ptr< LIB_SYMBOL > LIB_SYMBOL_SPTR
shared pointer to LIB_SYMBOL
bool AreDefaultFieldsCorrect(const std::vector< SCH_FIELD > &aFields)
Predicate to check that the mandatory fields look sensible.
bool FieldNameIdMatches(const SCH_FIELD &aField, const std::string &aExpectedName, int aExpectedId)
Predicate to check a field name is as expected.
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
@ USER
The field ID hasn't been set yet; field is invalid.
@ DESCRIPTION
Field Description of part, i.e. "1/4W 1% Metal Film Resistor".
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ DATASHEET
name of datasheet
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
BOOST_CHECK_EQUAL(ret, c.m_exp_result)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(DefaultProperties)
Declare the test suite.
BOOST_CHECK_PREDICATE(ArePolylineEndPointsNearCircle,(chain)(c.m_geom.m_center_point)(radius)(accuracy+epsilon))
BOOST_TEST_CONTEXT("Test Clearance")