20#include <boost/test/unit_test.hpp>
37 auto footprint = std::make_unique<FOOTPRINT>( board );
38 auto pad =
new PAD( footprint.get() );
39 pad->SetNumber(
"1" );
44 footprint->Add(
pad );
46 FOOTPRINT* liveFootprint = footprint.get();
47 board->
Add( footprint.release() );
49 auto image = std::unique_ptr<FOOTPRINT>(
static_cast<FOOTPRINT*
>( liveFootprint->
Clone() ) );
58 BOOST_CHECK( resolved != originalPad );
68 auto shape = std::make_unique<PCB_SHAPE>( board );
73 board->
Add( shape.release() );
75 const_cast<KIID&
>( liveShape->
m_Uuid ) = newId;
77 BOOST_CHECK( board->
ResolveItem( oldId,
true ) ==
nullptr );
88 auto shape = std::make_unique<PCB_SHAPE>( board );
93 board->
Add( shape.release() );
94 const_cast<KIID&
>( liveShape->
m_Uuid ) = newId;
108 auto shape = std::make_unique<PCB_SHAPE>( board );
113 board->
Add( shape.release() );
116 BOOST_CHECK( liveShape->
m_Uuid == newId );
129 auto footprint = std::make_unique<FOOTPRINT>( board );
130 auto pad =
new PAD( footprint.get() );
135 footprint->Add(
pad );
136 board->
Add( footprint.release() );
140 BOOST_CHECK( livePad->
m_Uuid == newId );
153 auto shape = std::make_unique<PCB_SHAPE>( board );
158 board->
Add( shape.release() );
160 const_cast<KIID&
>( liveShape->
m_Uuid ) = newId;
175 auto footprint = std::make_unique<FOOTPRINT>( board );
176 FOOTPRINT* liveFootprint = footprint.get();
179 auto shape = std::make_unique<PCB_SHAPE>( board );
181 const KIID originalShapeId = liveShape->
m_Uuid;
183 board->
Add( footprint.release() );
184 board->
Add( shape.release() );
186 const_cast<KIID&
>( liveShape->
m_Uuid ) = claimedId;
189 BOOST_CHECK( liveFootprint->
m_Uuid == claimedId );
190 BOOST_CHECK( liveShape->
m_Uuid != claimedId );
191 BOOST_CHECK( liveShape->
m_Uuid != originalShapeId );
193 BOOST_CHECK( board->
ResolveItem( originalShapeId,
true ) ==
nullptr );
211 auto footprint = std::make_unique<FOOTPRINT>( board );
212 auto pad =
new PAD( footprint.get() );
213 pad->SetNumber(
"1" );
215 const KIID padId =
pad->m_Uuid;
216 footprint->Add(
pad );
218 FOOTPRINT* liveFootprint = footprint.get();
219 board->
Add( footprint.release() );
227 const bool staleEntrySurvived = board->
GetItemByIdCache().contains( padId );
232 BOOST_CHECK( !staleEntrySurvived );
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
void SwapItemData(BOARD_ITEM *aImage)
Swap data between aItem and aImage.
void SetUuid(const KIID &aUuid)
Information pertinent to a Pcbnew printed circuit board.
void CacheItemById(BOARD_ITEM *aItem) const
Add an item to the item-by-id cache.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
void RebindItemUuid(BOARD_ITEM *aItem, const KIID &aNewId)
Rebind the UUID of an attached item and keep the item-by-id cache coherent.
int RepairDuplicateItemUuids()
Rebind duplicate attached-item UUIDs so each live board item has a unique ID.
const std::unordered_map< KIID, BOARD_ITEM * > & GetItemByIdCache() const
BOARD_ITEM * ResolveItem(const KIID &aID, bool aAllowNullptrReturn=false) const
KICAD_T Type() const
Returns the type of object.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_CASE(SwapItemDataReindexesFootprintChildren)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL(result, "25.4")
@ PCB_PAD_T
class PAD, a pad in a footprint