62 BOOST_CHECK_EQUAL( m_part_no_data.GetName(),
"part_name" );
65 BOOST_CHECK_EQUAL( m_part_no_data.GetLibraryName(),
"" );
66 BOOST_CHECK_EQUAL( m_part_no_data.GetLib(),
nullptr );
69 BOOST_CHECK_EQUAL( m_part_no_data.IsRoot(),
true );
70 BOOST_CHECK_EQUAL( m_part_no_data.IsAlias(),
false );
71 BOOST_CHECK_EQUAL( m_part_no_data.SharedPtr().use_count(), 2 );
74 BOOST_CHECK_EQUAL( m_part_no_data.GetUnitCount(), 1 );
75 BOOST_CHECK_EQUAL( m_part_no_data.IsMulti(),
false );
78 BOOST_CHECK_EQUAL( m_part_no_data.HasAlternateBodyStyle(),
false );
89 BOOST_CHECK_EQUAL( m_part_no_data.GetAllLibPins().size(), 0 );
98 std::vector<SCH_FIELD> fields;
99 m_part_no_data.GetFields( fields );
126 std::vector<SCH_FIELD> fields;
127 m_part_no_data.GetFields( fields );
130 const std::string newFieldName =
"new_field";
131 wxString nonConstNewFieldName = newFieldName;
132 fields.push_back(
SCH_FIELD(
nullptr, 42, nonConstNewFieldName ) );
135 m_part_no_data.SetFields( fields );
148 SCH_FIELD* gotNewField = m_part_no_data.GetFieldById( 42 );
150 BOOST_REQUIRE_NE( gotNewField,
nullptr );
156 gotNewField = m_part_no_data.FindField( newFieldName );
158 BOOST_REQUIRE_NE( gotNewField,
nullptr );
184 const std::vector<TEST_LIB_SYMBOL_SUBREF_CASE> cases = {
352 for(
const auto& c : cases )
355 "Subref: " << c.m_index <<
", " << c.m_addSep <<
" -> '" << c.m_expSubRef <<
"'" )
358 BOOST_CHECK_EQUAL( subref, c.m_expSubRef );
373 BOOST_CHECK_EQUAL( m_part_no_data.Compare( m_part_no_data ), 0 );
379 testPart.
SetName(
"tart_name" );
380 BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
381 testPart.
SetName(
"cart_name" );
382 BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
383 testPart.
SetName(
"part_name" );
389 BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
390 id.SetLibItemName(
"cart_name" );
392 BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
393 id.SetLibItemName(
"part_name" );
398 BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
400 m_part_no_data.SetUnitCount( 2 );
401 BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
402 m_part_no_data.SetUnitCount( 1 );
406 BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
408 m_part_no_data.SetPower();
409 BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
410 m_part_no_data.SetNormal();
416 m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[
SCH_SHAPE_T].front() );
421 m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[
SCH_SHAPE_T].front() );
427 m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[
SCH_SHAPE_T].front() );
429 m_part_no_data.AddDrawItem(
new SCH_PIN( &m_part_no_data ) );
431 m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[
SCH_PIN_T].front() );
434 wxArrayString footPrintFilters;
435 BOOST_CHECK( m_part_no_data.GetFPFilters() == footPrintFilters );
436 footPrintFilters.Add(
"b" );
439 m_part_no_data.SetFPFilters( footPrintFilters );
440 footPrintFilters.Clear();
443 footPrintFilters.Clear();
444 m_part_no_data.SetFPFilters( footPrintFilters );
448 m_part_no_data.SetDescription(
"b" );
451 m_part_no_data.SetDescription(
"a" );
453 m_part_no_data.SetDescription(
"c" );
455 m_part_no_data.SetDescription( wxEmptyString );
459 m_part_no_data.SetKeyWords(
"b" );
462 m_part_no_data.SetKeyWords(
"a" );
464 m_part_no_data.SetKeyWords(
"c" );
466 m_part_no_data.SetKeyWords( wxEmptyString );
480 m_part_no_data.LockUnits(
true );
482 m_part_no_data.LockUnits(
false );
488 m_part_no_data.SetExcludedFromBOM(
true );
490 m_part_no_data.SetExcludedFromBOM(
false );
496 m_part_no_data.SetExcludedFromBoard(
true );
498 m_part_no_data.SetExcludedFromBoard(
false );
501 m_part_no_data.SetShowPinNames(
false );
503 m_part_no_data.SetShowPinNames(
true );
509 m_part_no_data.SetShowPinNumbers(
false );
511 m_part_no_data.SetShowPinNumbers(
true );
530 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, 1 ).size() == 0 );
534 m_part_no_data.AddDrawItem( pin1 );
535 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 0, 0 ).size() == 1 );
539 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, 0 ).size() == 1 );
543 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, 1 ).size() == 1 );
548 m_part_no_data.SetUnitCount( 2 );
552 m_part_no_data.AddDrawItem( pin2 );
553 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 2, 2 ).size() == 1 );
557 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, 1 ).size() == 0 );
558 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 2, 1 ).size() == 1 );
560 m_part_no_data.RemoveDrawItem( pin2 );
561 m_part_no_data.RemoveDrawItem( pin1 );
562 m_part_no_data.RemoveDrawItem( &*m_part_no_data.GetDrawItems().begin() );
572 BOOST_CHECK( m_part_no_data.GetUnitDrawItems().size() == 0 );
577 m_part_no_data.AddDrawItem( pin1 );
578 std::vector<struct LIB_SYMBOL_UNIT> units = m_part_no_data.GetUnitDrawItems();
579 BOOST_CHECK( units.size() == 1 );
580 BOOST_CHECK( units[0].m_unit == 0 );
581 BOOST_CHECK( units[0].m_bodyStyle == 0 );
582 BOOST_CHECK( units[0].m_items[0] == pin1 );
591 std::unique_ptr<LIB_SYMBOL> parent = std::make_unique<LIB_SYMBOL>(
"parent" );
592 BOOST_CHECK( parent->IsRoot() );
593 BOOST_CHECK_EQUAL( parent->GetInheritanceDepth(), 0 );
595 std::unique_ptr<LIB_SYMBOL> ref = std::make_unique<LIB_SYMBOL>( *parent );
597 std::unique_ptr<LIB_SYMBOL> child = std::make_unique<LIB_SYMBOL>(
"child", parent.get() );
598 BOOST_CHECK( child->IsAlias() );
599 BOOST_CHECK_EQUAL( child->GetInheritanceDepth(), 1 );
601 std::unique_ptr<LIB_SYMBOL> grandChild = std::make_unique<LIB_SYMBOL>(
"grandchild",
603 BOOST_CHECK( grandChild->IsAlias() );
604 BOOST_CHECK_EQUAL( grandChild->GetInheritanceDepth(), 2 );
606 BOOST_CHECK( parent->GetRootSymbol().get() == parent.get() );
607 BOOST_CHECK( child->GetRootSymbol().get() == parent.get() );
608 BOOST_CHECK( grandChild->GetRootSymbol().get() == parent.get() );
611 BOOST_CHECK( parentRef );
612 BOOST_CHECK( parentRef == parent->SharedPtr() );
613 BOOST_CHECK_EQUAL( parent->SharedPtr().use_count(), 3 );
616 BOOST_CHECK( childRef );
617 BOOST_CHECK( childRef == child->SharedPtr() );
618 BOOST_CHECK_EQUAL( child->SharedPtr().use_count(), 3 );
620 BOOST_CHECK_EQUAL( child->GetUnitCount(), 1 );
621 parent->SetUnitCount( 4 );
622 BOOST_CHECK_EQUAL( child->GetUnitCount(), 4 );
623 parent->SetUnitCount( 1 );
625 parent->GetDatasheetField().SetText(
"https://kicad/resistors.pdf" );
626 ref->GetDatasheetField().SetText(
"https://kicad/resistors.pdf" );
628 BOOST_CHECK( *parent == *ref );
630 ref->SetName(
"child" );
633 child->AddField( field );
638 ref->AddField( field );
641 BOOST_CHECK( *ref == *child->Flatten() );
643 ref->SetName(
"grandchild" );
646 grandChild->AddField( field );
651 ref->AddField( field );
654 BOOST_CHECK( *ref == *grandChild->Flatten() );
656 BOOST_CHECK_EQUAL( grandChild->Flatten()->GetDatasheetField().GetText(),
657 "https://kicad/resistors.pdf" );
660 BOOST_CHECK_EQUAL( child->GetUnitCount(), 1 );
663 BOOST_CHECK_EQUAL( parent->SharedPtr().use_count(), 2 );
672 std::shared_ptr<LIB_SYMBOL>
copy = std::make_shared<LIB_SYMBOL>( m_part_no_data );
673 BOOST_CHECK( m_part_no_data == *
copy.get() );
682 std::unique_ptr<LIB_SYMBOL> symbol = std::make_unique<LIB_SYMBOL>(
"power" );
684 pin->SetNumber(
"1" );
686 pin->SetVisible(
false );
687 symbol->AddDrawItem(
pin );
689 BOOST_CHECK( !symbol->IsPower() );
690 BOOST_CHECK( symbol->IsNormal() );
693 BOOST_CHECK( symbol->IsPower() );
694 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)
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
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
@ ARC
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.
@ DATASHEET_FIELD
name of datasheet
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 5 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
@ DESCRIPTION_FIELD
Field Description of part, i.e. "1/4W 1% Metal Film Resistor".
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(DefaultProperties)
Declare the test suite.