KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_board_connected_items.cpp File Reference
#include <boost/test/unit_test.hpp>
#include <board.h>
#include <board_connected_item.h>
#include <footprint.h>
#include <pad.h>
#include <pcb_shape.h>
#include <pcb_track.h>
#include <zone.h>
#include <netinfo.h>
#include <pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h>

Go to the source code of this file.

Classes

struct  BOARD_CONNECTED_ITEMS_FIXTURE
 

Functions

 BOOST_AUTO_TEST_CASE (AllConnectedItems_IncludesFootprintShapes)
 Verify that AllConnectedItems includes copper shapes inside footprints.
 
 BOOST_AUTO_TEST_CASE (AllConnectedItems_IncludesFootprintZones)
 Verify that AllConnectedItems includes zones inside footprints.
 
 BOOST_AUTO_TEST_CASE (MapNets_RemapsFootprintShapes)
 Verify that MapNets remaps net pointers for shapes inside footprints.
 
 BOOST_AUTO_TEST_CASE (MapNets_FootprintShapeSurvivesSourceBoardDeletion)
 Verify that after MapNets and source board destruction, pasted items can still be serialized without crashing.
 
 BOOST_AUTO_TEST_CASE (ThievingZone_RejectsNetCodeViaBasePointer)
 Verify that copper-thieving zones reject any non-zero netcode assignment.
 
 BOOST_AUTO_TEST_CASE (ThievingZone_RejectsSetNetViaBasePointer)
 SetNet bypasses SetNetCode entirely (importers and API deserialize use it directly).
 
 BOOST_AUTO_TEST_CASE (ThievingZone_DropsNetWhenFillModeBecomesThieving)
 Switching a netted solid copper zone to copper-thieving fill mode must drop the assigned net atomically, otherwise the netless invariant is breakable by reordering operations in the dialog or properties manager.
 
 BOOST_AUTO_TEST_CASE (ThievingZone_ReducesToSingleLayerWhenFillModeBecomesThieving)
 Conversion to thieving must clamp a multi-layer zone to a single layer.
 
 BOOST_AUTO_TEST_CASE (ThievingZone_SetLayerSetClampsToOneLayer)
 Direct SetLayerSet on a thieving zone (protobuf, API) must clamp to one layer.
 
 BOOST_AUTO_TEST_CASE (SolidCopperZone_AcceptsNetCodeViaBasePointer)
 A solid-fill copper zone is not subject to the thieving netless invariant and must accept the assignment.
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/10]

BOOST_AUTO_TEST_CASE ( AllConnectedItems_IncludesFootprintShapes )

Verify that AllConnectedItems includes copper shapes inside footprints.

This is a regression test for https://gitlab.com/kicad/code/kicad/-/issues/23093 where footprint-level shapes on copper were missed by AllConnectedItems, causing MapNets to leave dangling NETINFO_ITEM pointers after paste.

Definition at line 67 of file test_board_connected_items.cpp.

References FOOTPRINT::Add(), PADSTACK::ALL_LAYERS, BOOST_AUTO_TEST_CASE(), BOOST_CHECK_MESSAGE(), CIRCLE, F_Cu, FOOTPRINT, PAD, pad, pcbIUScale, SEGMENT, EDA_SHAPE::SetEnd(), PCB_SHAPE::SetLayer(), and EDA_SHAPE::SetStart().

◆ BOOST_AUTO_TEST_CASE() [2/10]

BOOST_AUTO_TEST_CASE ( AllConnectedItems_IncludesFootprintZones )

Verify that AllConnectedItems includes zones inside footprints.

Definition at line 105 of file test_board_connected_items.cpp.

References FOOTPRINT::Add(), ZONE::AppendCorner(), BOOST_CHECK_MESSAGE(), F_Cu, FOOTPRINT, pcbIUScale, and ZONE::SetLayer().

◆ BOOST_AUTO_TEST_CASE() [3/10]

BOOST_AUTO_TEST_CASE ( MapNets_FootprintShapeSurvivesSourceBoardDeletion )

Verify that after MapNets and source board destruction, pasted items can still be serialized without crashing.

This is the exact scenario from issue 23093.

Definition at line 182 of file test_board_connected_items.cpp.

References FOOTPRINT::Add(), PADSTACK::ALL_LAYERS, BOOST_CHECK_MESSAGE(), CIRCLE, F_Cu, FOOTPRINT, PCB_IO_KICAD_SEXPR::Format(), STRING_FORMATTER::GetString(), output, PAD, pad, pcbIUScale, SEGMENT, EDA_SHAPE::SetEnd(), PCB_SHAPE::SetLayer(), BOARD_CONNECTED_ITEM::SetNet(), PCB_IO_KICAD_SEXPR::SetOutputFormatter(), EDA_ITEM::SetParent(), and EDA_SHAPE::SetStart().

◆ BOOST_AUTO_TEST_CASE() [4/10]

BOOST_AUTO_TEST_CASE ( MapNets_RemapsFootprintShapes )

Verify that MapNets remaps net pointers for shapes inside footprints.

Simulates the paste scenario where items from a clipboard board need their net pointers remapped to the destination board's NETINFO_LIST.

Definition at line 137 of file test_board_connected_items.cpp.

References FOOTPRINT::Add(), PADSTACK::ALL_LAYERS, BOOST_CHECK_MESSAGE(), CIRCLE, F_Cu, FOOTPRINT, BOARD_CONNECTED_ITEM::GetNet(), BOARD_CONNECTED_ITEM::GetNetname(), PAD, pad, pcbIUScale, SEGMENT, EDA_SHAPE::SetEnd(), PCB_SHAPE::SetLayer(), BOARD_CONNECTED_ITEM::SetNet(), and EDA_SHAPE::SetStart().

◆ BOOST_AUTO_TEST_CASE() [5/10]

BOOST_AUTO_TEST_CASE ( SolidCopperZone_AcceptsNetCodeViaBasePointer )

A solid-fill copper zone is not subject to the thieving netless invariant and must accept the assignment.

Regression guard for the override.

Definition at line 337 of file test_board_connected_items.cpp.

References BOOST_CHECK_EQUAL(), BOARD_CONNECTED_ITEM::GetNetCode(), POLYGONS, ZONE::SetFillMode(), and BOARD_CONNECTED_ITEM::SetNetCode().

◆ BOOST_AUTO_TEST_CASE() [6/10]

BOOST_AUTO_TEST_CASE ( ThievingZone_DropsNetWhenFillModeBecomesThieving )

Switching a netted solid copper zone to copper-thieving fill mode must drop the assigned net atomically, otherwise the netless invariant is breakable by reordering operations in the dialog or properties manager.

Definition at line 286 of file test_board_connected_items.cpp.

References BOOST_CHECK_EQUAL(), COPPER_THIEVING, BOARD_CONNECTED_ITEM::GetNetCode(), ZONE::SetFillMode(), and ZONE::SetNetCode().

◆ BOOST_AUTO_TEST_CASE() [7/10]

BOOST_AUTO_TEST_CASE ( ThievingZone_ReducesToSingleLayerWhenFillModeBecomesThieving )

Conversion to thieving must clamp a multi-layer zone to a single layer.

Definition at line 304 of file test_board_connected_items.cpp.

References B_Cu, BOOST_CHECK_EQUAL(), COPPER_THIEVING, F_Cu, ZONE::GetLayer(), ZONE::GetLayerSet(), In1_Cu, ZONE::SetFillMode(), and ZONE::SetLayerSet().

◆ BOOST_AUTO_TEST_CASE() [8/10]

BOOST_AUTO_TEST_CASE ( ThievingZone_RejectsNetCodeViaBasePointer )

Verify that copper-thieving zones reject any non-zero netcode assignment.

Thieving zones are dummy plating-balance copper and must remain netless. The invariant has to hold even when the caller uses a base-class pointer, since paste/clipboard, properties manager, and PRL load all reach the setter via BOARD_CONNECTED_ITEM*.

Definition at line 244 of file test_board_connected_items.cpp.

References BOOST_CHECK_EQUAL(), COPPER_THIEVING, BOARD_CONNECTED_ITEM::GetNetCode(), ZONE::SetFillMode(), and BOARD_CONNECTED_ITEM::SetNetCode().

◆ BOOST_AUTO_TEST_CASE() [9/10]

BOOST_AUTO_TEST_CASE ( ThievingZone_RejectsSetNetViaBasePointer )

SetNet bypasses SetNetCode entirely (importers and API deserialize use it directly).

Verify the ZONE override drops the netinfo for thieving zones even when called through the base-class pointer.

Definition at line 265 of file test_board_connected_items.cpp.

References COPPER_THIEVING, BOARD_CONNECTED_ITEM::GetNet(), ZONE::SetFillMode(), and BOARD_CONNECTED_ITEM::SetNet().

◆ BOOST_AUTO_TEST_CASE() [10/10]

BOOST_AUTO_TEST_CASE ( ThievingZone_SetLayerSetClampsToOneLayer )

Direct SetLayerSet on a thieving zone (protobuf, API) must clamp to one layer.

Definition at line 320 of file test_board_connected_items.cpp.

References B_Cu, BOOST_CHECK_EQUAL(), COPPER_THIEVING, F_Cu, ZONE::GetLayerSet(), In1_Cu, ZONE::SetFillMode(), and ZONE::SetLayerSet().