KiCad PCB EDA Suite
test_sch_pin.cpp File Reference

Go to the source code of this file.

Classes

class  TEST_SCH_PIN_FIXTURE
 

Functions

 BOOST_AUTO_TEST_CASE (DefaultProperties)
 Declare the test suite. More...
 
 BOOST_AUTO_TEST_CASE (Assign)
 Check the assignment operator. More...
 
 BOOST_AUTO_TEST_CASE (Copy)
 Check the copy ctor. More...
 
 BOOST_AUTO_TEST_CASE (PinDangling)
 Check the pin dangling flag. More...
 
 BOOST_AUTO_TEST_CASE (PinNumbering)
 Check the pin labelling. More...
 
 BOOST_AUTO_TEST_CASE (PinNumberingPower)
 Check the pin labelling when it's a power pin. More...
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/6]

BOOST_AUTO_TEST_CASE ( DefaultProperties  )

Declare the test suite.

Check basic properties of an un-modified SCH_PIN object

Definition at line 80 of file test_sch_pin.cpp.

81 {
82  BOOST_CHECK_EQUAL( m_sch_pin->GetParentSymbol(), m_parent_symbol );
83 
84  // Note: local coord system is upside-down; schematic coord system is not.
85  BOOST_CHECK_EQUAL( m_sch_pin->GetLocalPosition(), wxPoint( 1, -2 ) );
86  BOOST_CHECK_EQUAL( m_sch_pin->GetPosition(), wxPoint( 2, 4 ) );
87 
88  BOOST_CHECK_EQUAL( m_sch_pin->IsVisible(), m_lib_pin->IsVisible() );
89  BOOST_CHECK_EQUAL( m_sch_pin->GetName(), m_lib_pin->GetName() );
90  BOOST_CHECK_EQUAL( m_sch_pin->GetNumber(), m_lib_pin->GetNumber() );
91 
92  BOOST_CHECK( ( m_sch_pin->GetType() == m_lib_pin->GetType() ) );
93 
94  BOOST_CHECK_EQUAL( m_sch_pin->IsPowerConnection(), m_lib_pin->IsPowerConnection() );
95 }
BOOST_CHECK(v2.Cross(v1)==1)

References BOOST_CHECK().

◆ BOOST_AUTO_TEST_CASE() [2/6]

BOOST_AUTO_TEST_CASE ( Assign  )

Check the assignment operator.

Definition at line 100 of file test_sch_pin.cpp.

101 {
102  SCH_PIN assigned = *m_sch_pin;
103 
104  BOOST_CHECK_EQUAL( assigned.GetParentSymbol(), m_parent_symbol );
105  BOOST_CHECK_EQUAL( assigned.GetNumber(), m_lib_pin->GetNumber() );
106 }
SCH_COMPONENT * GetParentSymbol() const
Definition: sch_pin.cpp:141
wxString GetNumber() const
Definition: sch_pin.h:107

References SCH_PIN::GetNumber(), and SCH_PIN::GetParentSymbol().

◆ BOOST_AUTO_TEST_CASE() [3/6]

BOOST_AUTO_TEST_CASE ( Copy  )

Check the copy ctor.

Definition at line 111 of file test_sch_pin.cpp.

112 {
113  SCH_PIN copied( *m_sch_pin );
114 
115  BOOST_CHECK_EQUAL( copied.GetParentSymbol(), m_parent_symbol );
116  BOOST_CHECK_EQUAL( copied.GetNumber(), m_lib_pin->GetNumber() );
117 }

References SCH_PIN::GetNumber(), and SCH_PIN::GetParentSymbol().

◆ BOOST_AUTO_TEST_CASE() [4/6]

BOOST_AUTO_TEST_CASE ( PinDangling  )

Check the pin dangling flag.

Definition at line 122 of file test_sch_pin.cpp.

123 {
124  // dangles by default
125  BOOST_CHECK_EQUAL( m_sch_pin->IsDangling(), true );
126 
127  // all you have to do to un-dangle is say so
128  m_sch_pin->SetIsDangling( false );
129  BOOST_CHECK_EQUAL( m_sch_pin->IsDangling(), false );
130 
131  // and the same to re-dangle
132  m_sch_pin->SetIsDangling( true );
133  BOOST_CHECK_EQUAL( m_sch_pin->IsDangling(), true );
134 }

◆ BOOST_AUTO_TEST_CASE() [5/6]

BOOST_AUTO_TEST_CASE ( PinNumbering  )

Check the pin labelling.

Definition at line 139 of file test_sch_pin.cpp.

140 {
142 
143  const wxString name = m_sch_pin->GetDefaultNetName( path );
144  BOOST_CHECK_EQUAL( name, "Net-(U2-Pad42)" );
145 
146  // do it again: this should now (transparently) go though the net name map
147  // can't really check directly, but coverage tools should see this
148  const wxString map_name = m_sch_pin->GetDefaultNetName( path );
149  BOOST_CHECK_EQUAL( map_name, name );
150 }
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
const char * name
Definition: DXF_plotter.cpp:59

References name, and path.

◆ BOOST_AUTO_TEST_CASE() [6/6]

BOOST_AUTO_TEST_CASE ( PinNumberingPower  )

Check the pin labelling when it's a power pin.

Definition at line 155 of file test_sch_pin.cpp.

156 {
157  // but if we set isPower...
158  m_lib_pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
159  m_parent_part->SetPower();
160 
161  // and update symbol from library...
163  delete m_parent_symbol;
164  m_parent_symbol = new SCH_COMPONENT( *m_parent_part, m_parent_part->GetLibId(),
165  &path, 0, 0, wxPoint( 1, 2 ) );
166  m_parent_symbol->SetRef( &path, "U2" );
167  m_parent_symbol->UpdatePins();
168 
169  m_sch_pin = m_parent_symbol->GetPins( &path )[0];
170 
171  // ... then the name is just the pin name
172  const wxString pwr_name = m_sch_pin->GetDefaultNetName( path );
173  BOOST_CHECK_EQUAL( pwr_name, "pinname" );
174 }
power input (GND, VCC for ICs). Must be connected to a power output.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
Definition: sch_symbol.cpp:471
Schematic symbol object.
Definition: sch_symbol.h:78

References path, PT_POWER_IN, and SCH_COMPONENT::SetRef().