KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_lib_part.cpp File Reference

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 "lib_field_test_utils.h"

Go to the source code of this file.

Classes

class  TEST_LIB_SYMBOL_FIXTURE
 
struct  TEST_LIB_SYMBOL_SUBREF_CASE
 

Functions

 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 (SubReference)
 Test the subreference indexing.
 
 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.
 

Detailed Description

Test suite for LIB_SYMBOL.

Definition in file test_lib_part.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/13]

BOOST_AUTO_TEST_CASE ( AddedDrawItems )

Test adding draw items to a LIB_SYMBOL.

Definition at line 155 of file test_lib_part.cpp.

◆ BOOST_AUTO_TEST_CASE() [2/13]

BOOST_AUTO_TEST_CASE ( AddedFields )

Test adding fields to a LIB_SYMBOL.

Definition at line 124 of file test_lib_part.cpp.

References KI_TEST::AreDefaultFieldsCorrect(), BOOST_CHECK_PREDICATE(), KI_TEST::FieldNameIdMatches(), and USER.

◆ BOOST_AUTO_TEST_CASE() [3/13]

◆ BOOST_AUTO_TEST_CASE() [4/13]

BOOST_AUTO_TEST_CASE ( CopyConstructor )

Check the copy constructor.

Definition at line 666 of file test_lib_part.cpp.

References copy.

◆ BOOST_AUTO_TEST_CASE() [5/13]

BOOST_AUTO_TEST_CASE ( DefaultDrawings )

Check the drawings on a "blank" LIB_SYMBOL.

Definition at line 85 of file test_lib_part.cpp.

References BOOST_CHECK_EQUAL().

◆ BOOST_AUTO_TEST_CASE() [6/13]

BOOST_AUTO_TEST_CASE ( DefaultFields )

Check the default fields are present as expected.

Definition at line 96 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() [7/13]

BOOST_AUTO_TEST_CASE ( DefaultProperties )

Declare the test suite.

Check that we can get the basic properties out as expected

Definition at line 60 of file test_lib_part.cpp.

References BOOST_AUTO_TEST_CASE(), and BOOST_CHECK_EQUAL().

◆ BOOST_AUTO_TEST_CASE() [8/13]

BOOST_AUTO_TEST_CASE ( GetUnitDrawItems )

Check the fetch unit draw items code.

Definition at line 566 of file test_lib_part.cpp.

References SCH_PIN::SetNumber().

◆ BOOST_AUTO_TEST_CASE() [9/13]

BOOST_AUTO_TEST_CASE ( GetUnitItems )

Check the fetch unit items code.

Definition at line 524 of file test_lib_part.cpp.

References SCH_ITEM::SetBodyStyle(), SCH_PIN::SetNumber(), and SCH_ITEM::SetUnit().

◆ BOOST_AUTO_TEST_CASE() [10/13]

BOOST_AUTO_TEST_CASE ( Inheritance )

Check inheritance support.

Definition at line 586 of file test_lib_part.cpp.

References BOOST_CHECK_EQUAL(), DATASHEET, EDA_ITEM::SetParent(), SCH_FIELD::SetText(), and USER.

◆ BOOST_AUTO_TEST_CASE() [11/13]

BOOST_AUTO_TEST_CASE ( IsPowerTest )

Check the power and legacy power symbol tests.

Definition at line 676 of file test_lib_part.cpp.

References pin, and PT_POWER_IN.

◆ BOOST_AUTO_TEST_CASE() [12/13]

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 715 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() [13/13]

BOOST_AUTO_TEST_CASE ( SubReference )

Test the subreference indexing.

Definition at line 171 of file test_lib_part.cpp.

References BOOST_CHECK_EQUAL(), BOOST_TEST_CONTEXT(), and LIB_SYMBOL::LetterSubReference().