|
KiCad PCB EDA Suite
|
Test suite for LIB_SYMBOL. More...
#include <qa_utils/wx_utils/unit_test_utils.h>#include <sch_shape.h>#include <sch_pin.h>#include <lib_symbol.h>#include <locale_io.h>#include <sch_file_versions.h>#include <sch_io/sch_io.h>#include <sch_io/sch_io_mgr.h>#include <wx/file.h>#include <wx/filename.h>#include "lib_field_test_utils.h"Go to the source code of this file.
Classes | |
| class | TEST_LIB_SYMBOL_FIXTURE |
| class | SCOPED_TEMP_LIB |
| A temporary symbol library that is removed when it goes out of scope. More... | |
| struct | TEST_LIB_SYMBOL_SUBREF_CASE |
Functions | |
| static int | alternateBodyStyleItemCount (LIB_SYMBOL &aSymbol) |
| Return the number of draw items belonging to a body style beyond the standard one. | |
| static std::unique_ptr< LIB_SYMBOL > | loadDeMorganSymbol () |
| Load 4001, a four unit NOR gate carrying a De Morgan alternate body style. | |
| static void | saveToLib (const wxString &aLibPath, const LIB_SYMBOL &aSymbol) |
| Write a symbol to its own library file. | |
| BOOST_AUTO_TEST_CASE (DefaultProperties) | |
| Declare the test suite. | |
| BOOST_AUTO_TEST_CASE (DefaultDrawings) | |
| Check the drawings on a "blank" LIB_SYMBOL. | |
| BOOST_AUTO_TEST_CASE (DefaultFields) | |
| Check the default fields are present as expected. | |
| BOOST_AUTO_TEST_CASE (AddedFields) | |
| Test adding fields to a LIB_SYMBOL. | |
| BOOST_AUTO_TEST_CASE (AddedDrawItems) | |
| Test adding draw items to a LIB_SYMBOL. | |
| BOOST_AUTO_TEST_CASE (StackedPinNumberLookup) | |
| A stacked pin is one drawn pin standing for several numbered contacts, written as a bracketed list. | |
| BOOST_AUTO_TEST_CASE (RangeStackedPinNumberLookup) | |
| The same, for range notation. | |
| BOOST_AUTO_TEST_CASE (SubReference) | |
| Test the subreference indexing. | |
| BOOST_AUTO_TEST_CASE (NativeBezierComparisonHandlesUnequalCaches) | |
| BOOST_AUTO_TEST_CASE (Compare) | |
| Check the compare method. | |
| BOOST_AUTO_TEST_CASE (GetUnitItems) | |
| Check the fetch unit items code. | |
| BOOST_AUTO_TEST_CASE (GetUnitDrawItems) | |
| Check the fetch unit draw items code. | |
| BOOST_AUTO_TEST_CASE (Inheritance) | |
| Check inheritance support. | |
| BOOST_AUTO_TEST_CASE (CopyConstructor) | |
| Check the copy constructor. | |
| BOOST_AUTO_TEST_CASE (IsPowerTest) | |
| Check the power and legacy power symbol tests. | |
| BOOST_AUTO_TEST_CASE (SetUnitCountRejectsInvalidValues) | |
| Regression test for https://gitlab.com/kicad/code/kicad/-/issues/23788. | |
| BOOST_AUTO_TEST_CASE (DeleteDeMorganBodyStyleDrawItems) | |
| Regression test for https://gitlab.com/kicad/code/kicad/-/issues/25004. | |
| BOOST_AUTO_TEST_CASE (OrphanedBodyStyleItemsAreNotLoaded) | |
| Libraries already written with orphaned alternate drawings must load without them. | |
| BOOST_AUTO_TEST_CASE (NativeComparisonDetectsPinTypeChanges) | |
| BOOST_AUTO_TEST_CASE (NativeComparisonDetectsAddedPins) | |
| BOOST_AUTO_TEST_CASE (NativeComparisonHonorsMissingAndExtraFieldFlags) | |
| BOOST_AUTO_TEST_CASE (NativeComparisonHonorsPinVisibilityFlag) | |
| BOOST_AUTO_TEST_CASE (NativeComparisonHonorsAlternateDefinitionFlag) | |
Test suite for LIB_SYMBOL.
Definition in file test_lib_part.cpp.
|
static |
Return the number of draw items belonging to a body style beyond the standard one.
Definition at line 87 of file test_lib_part.cpp.
References BASE, and LIB_SYMBOL::GetDrawItems().
Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
| BOOST_AUTO_TEST_CASE | ( | AddedDrawItems | ) |
Test adding draw items to a LIB_SYMBOL.
Definition at line 236 of file test_lib_part.cpp.
References BOOST_CHECK_EQUAL(), and pin.
| BOOST_AUTO_TEST_CASE | ( | AddedFields | ) |
Test adding fields to a LIB_SYMBOL.
Definition at line 205 of file test_lib_part.cpp.
References KI_TEST::AreDefaultFieldsCorrect(), BOOST_CHECK_PREDICATE(), KI_TEST::FieldNameIdMatches(), and USER.
| BOOST_AUTO_TEST_CASE | ( | Compare | ) |
Check the compare method.
Definition at line 528 of file test_lib_part.cpp.
References LIB_SYMBOL::AddDrawItem(), ARC, BOOST_CHECK_EQUAL(), LIB_SYMBOL::Compare(), copy, LIB_SYMBOL::GetDrawItems(), LIB_SYMBOL::GetLibId(), SYMBOL::GetPinNameOffset(), LAYER_DEVICE, LIB_SYMBOL::LockUnits(), RECTANGLE, LIB_SYMBOL::RemoveDrawItem(), SCH_PIN_T, SCH_SHAPE_T, LIB_SYMBOL::SetDescription(), SYMBOL::SetExcludedFromBoard(), SYMBOL::SetExcludedFromBOM(), SYMBOL::SetExcludedFromPosFiles(), LIB_SYMBOL::SetFPFilters(), LIB_SYMBOL::SetGlobalPower(), LIB_SYMBOL::SetKeyWords(), LIB_SYMBOL::SetLibId(), LIB_ID::SetLibItemName(), LIB_SYMBOL::SetName(), LIB_SYMBOL::SetNormal(), SYMBOL::SetPinNameOffset(), SYMBOL::SetShowPinNames(), SYMBOL::SetShowPinNumbers(), LIB_SYMBOL::SetUnitCount(), and SCH_ITEM::UUID.
| BOOST_AUTO_TEST_CASE | ( | CopyConstructor | ) |
| BOOST_AUTO_TEST_CASE | ( | DefaultDrawings | ) |
Check the drawings on a "blank" LIB_SYMBOL.
Definition at line 166 of file test_lib_part.cpp.
References BOOST_CHECK_EQUAL().
| BOOST_AUTO_TEST_CASE | ( | DefaultFields | ) |
Check the default fields are present as expected.
Definition at line 177 of file test_lib_part.cpp.
References KI_TEST::AreDefaultFieldsCorrect(), BOOST_CHECK_EQUAL(), BOOST_CHECK_PREDICATE(), DATASHEET, DESCRIPTION, KI_TEST::FieldNameIdMatches(), FOOTPRINT, REFERENCE, and VALUE.
| BOOST_AUTO_TEST_CASE | ( | DefaultProperties | ) |
Declare the test suite.
Check that we can get the basic properties out as expected
Definition at line 141 of file test_lib_part.cpp.
References BOOST_AUTO_TEST_CASE(), and BOOST_CHECK_EQUAL().
| BOOST_AUTO_TEST_CASE | ( | DeleteDeMorganBodyStyleDrawItems | ) |
Regression test for https://gitlab.com/kicad/code/kicad/-/issues/25004.
Dropping a symbol back to a single body style must delete the alternate drawings whichever order the caller updates the body style metadata in. DIALOG_LIB_SYMBOL_PROPERTIES cleared the De Morgan flag first, which made SetBodyStyleCount() see a previous count of 1 and skip the deletion. The orphans then drew on top of the standard body style because renderers ask for body style 0 (all) when a symbol has only one.
Definition at line 971 of file test_lib_part.cpp.
References alternateBodyStyleItemCount(), BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), and loadDeMorganSymbol().
| BOOST_AUTO_TEST_CASE | ( | GetUnitDrawItems | ) |
Check the fetch unit draw items code.
Definition at line 738 of file test_lib_part.cpp.
References BOOST_CHECK_EQUAL(), and pin1.
| BOOST_AUTO_TEST_CASE | ( | GetUnitItems | ) |
Check the fetch unit items code.
Definition at line 696 of file test_lib_part.cpp.
References pin1, SCH_ITEM::SetBodyStyle(), SCH_PIN::SetNumber(), and SCH_ITEM::SetUnit().
| BOOST_AUTO_TEST_CASE | ( | Inheritance | ) |
Check inheritance support.
Definition at line 793 of file test_lib_part.cpp.
References BOOST_CHECK_EQUAL(), DATASHEET, EDA_ITEM::SetParent(), SCH_FIELD::SetText(), and USER.
| BOOST_AUTO_TEST_CASE | ( | IsPowerTest | ) |
Check the power and legacy power symbol tests.
Definition at line 883 of file test_lib_part.cpp.
References pin, and PT_POWER_IN.
| BOOST_AUTO_TEST_CASE | ( | NativeBezierComparisonHandlesUnequalCaches | ) |
Definition at line 494 of file test_lib_part.cpp.
References BEZIER, BOOST_REQUIRE(), empty(), EDA_SHAPE::GetBezierPoints(), loadDeMorganSymbol(), EDA_SHAPE::RebuildBezierToSegmentsPointsList(), SCH_SHAPE_T, EDA_SHAPE::SetBezierC1(), EDA_SHAPE::SetBezierC2(), EDA_SHAPE::SetEnd(), EDA_SHAPE::SetShape(), and EDA_SHAPE::SetStart().
| BOOST_AUTO_TEST_CASE | ( | NativeComparisonDetectsAddedPins | ) |
Definition at line 1049 of file test_lib_part.cpp.
References LIB_SYMBOL::AddDrawItem(), BOOST_REQUIRE(), LIB_SYMBOL::Compare(), LIB_SYMBOL::GetGraphicalPins(), SCH_ITEM::IDENTITY, loadDeMorganSymbol(), SCH_PIN::SetNumber(), SCH_ITEM::UNIT, and SCH_ITEM::UUID.
| BOOST_AUTO_TEST_CASE | ( | NativeComparisonDetectsPinTypeChanges | ) |
Definition at line 1028 of file test_lib_part.cpp.
References BOOST_REQUIRE(), LIB_SYMBOL::Compare(), LIB_SYMBOL::GetGraphicalPins(), SCH_ITEM::IDENTITY, loadDeMorganSymbol(), pin, PT_INPUT, PT_OUTPUT, SCH_ITEM::UNIT, and SCH_ITEM::UUID.
| BOOST_AUTO_TEST_CASE | ( | NativeComparisonHonorsAlternateDefinitionFlag | ) |
Definition at line 1112 of file test_lib_part.cpp.
References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), LIB_SYMBOL::Compare(), LIB_SYMBOL::GetGraphicalPins(), SCH_ITEM::IDENTITY, LINE, loadDeMorganSymbol(), name, pin, SCH_ITEM::PIN_ALT_DEFS, PT_INPUT, SCH_ITEM::UNIT, and SCH_ITEM::UUID.
| BOOST_AUTO_TEST_CASE | ( | NativeComparisonHonorsMissingAndExtraFieldFlags | ) |
Definition at line 1070 of file test_lib_part.cpp.
References LIB_SYMBOL::AddField(), BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), LIB_SYMBOL::Compare(), SCH_ITEM::EXTRA_FIELDS, LIB_SYMBOL::GetField(), SCH_ITEM::IDENTITY, loadDeMorganSymbol(), SCH_ITEM::MISSING_FIELDS, name, SCH_ITEM::UNIT, USER, and SCH_ITEM::UUID.
| BOOST_AUTO_TEST_CASE | ( | NativeComparisonHonorsPinVisibilityFlag | ) |
Definition at line 1091 of file test_lib_part.cpp.
References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), LIB_SYMBOL::Compare(), LIB_SYMBOL::GetGraphicalPins(), SCH_ITEM::IDENTITY, loadDeMorganSymbol(), pin, SCH_ITEM::PIN_VISIBILITIES, SCH_ITEM::UNIT, and SCH_ITEM::UUID.
| BOOST_AUTO_TEST_CASE | ( | OrphanedBodyStyleItemsAreNotLoaded | ) |
Libraries already written with orphaned alternate drawings must load without them.
The declared body style count is authoritative for V10 and later files.
Definition at line 1003 of file test_lib_part.cpp.
References alternateBodyStyleItemCount(), BASE, BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), LIB_SYMBOL::GetBodyStyleCount(), SCOPED_TEMP_LIB::GetPath(), LIB_SYMBOL::GetUnitCount(), LIB_SYMBOL::GetUnitDrawItems(), loadDeMorganSymbol(), and saveToLib().
| BOOST_AUTO_TEST_CASE | ( | RangeStackedPinNumberLookup | ) |
The same, for range notation.
The bracketed form must keep matching: it is the spelling that works today and is stored in existing symbols.
Definition at line 286 of file test_lib_part.cpp.
References pin.
| BOOST_AUTO_TEST_CASE | ( | SetUnitCountRejectsInvalidValues | ) |
Regression test for https://gitlab.com/kicad/code/kicad/-/issues/23788.
SetUnitCount() must reject values less than 1. Previously, an importer (Altium .schdoc) could pass a negative or zero unit count, which caused the deletion loop to erase the mandatory fields (REFERENCE, VALUE, etc.) because their m_unit (== 0) was greater than the requested aCount. The symbol then crashed later when GetReferenceField() returned a null pointer that was implicitly dereferenced.
Definition at line 922 of file test_lib_part.cpp.
References BOOST_CHECK_EQUAL(), CHECK_WX_ASSERT, DATASHEET, DESCRIPTION, FOOTPRINT, REFERENCE, LIB_SYMBOL::SetUnitCount(), and VALUE.
| BOOST_AUTO_TEST_CASE | ( | StackedPinNumberLookup | ) |
A stacked pin is one drawn pin standing for several numbered contacts, written as a bracketed list.
Both the list itself and each contact it names are pins of the symbol.
Definition at line 264 of file test_lib_part.cpp.
References pin.
| BOOST_AUTO_TEST_CASE | ( | SubReference | ) |
Test the subreference indexing.
Definition at line 312 of file test_lib_part.cpp.
References BOOST_CHECK_EQUAL(), BOOST_TEST_CONTEXT(), and LIB_SYMBOL::LetterSubReference().
|
static |
Load 4001, a four unit NOR gate carrying a De Morgan alternate body style.
Definition at line 104 of file test_lib_part.cpp.
References KI_TEST::GetEeschemaTestDataDir().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
|
static |
Write a symbol to its own library file.
Definition at line 122 of file test_lib_part.cpp.
Referenced by BOOST_AUTO_TEST_CASE().