20#include <boost/test/unit_test.hpp>
42 board.
Add( footprint );
45 footprint->
Pads().push_back(
pad );
57 std::deque<PAD*>& pads = footprint->
Pads();
58 pads.erase( std::find( pads.begin(), pads.end(),
pad ) );
61 BOOST_CHECK( board.
ResolveItem( padId,
true ) ==
nullptr );
76 BOOST_CHECK_NO_THROW(
delete dummy );
88 board->
Add( footprint );
91 footprint->
Pads().push_back(
pad );
98 std::deque<PAD*>& pads = footprint->
Pads();
99 pads.erase( std::find( pads.begin(), pads.end(),
pad ) );
103 BOOST_CHECK( !
pad->IsIndexedInBoard() );
104 BOOST_CHECK_NO_THROW(
delete pad );
112 auto footprint = std::make_unique<FOOTPRINT>( board );
113 auto pad =
new PAD( footprint.get() );
114 pad->SetNumber(
"1" );
119 footprint->Add(
pad );
121 FOOTPRINT* liveFootprint = footprint.get();
122 board->
Add( footprint.release() );
124 auto image = std::unique_ptr<FOOTPRINT>(
static_cast<FOOTPRINT*
>( liveFootprint->
Clone() ) );
133 BOOST_CHECK( resolved != originalPad );
143 auto shape = std::make_unique<PCB_SHAPE>( board );
148 board->
Add( shape.release() );
150 const_cast<KIID&
>( liveShape->
m_Uuid ) = newId;
152 BOOST_CHECK( board->
ResolveItem( oldId,
true ) ==
nullptr );
163 auto shape = std::make_unique<PCB_SHAPE>( board );
168 board->
Add( shape.release() );
169 const_cast<KIID&
>( liveShape->
m_Uuid ) = newId;
183 auto shape = std::make_unique<PCB_SHAPE>( board );
188 board->
Add( shape.release() );
191 BOOST_CHECK( liveShape->
m_Uuid == newId );
204 auto footprint = std::make_unique<FOOTPRINT>( board );
205 auto pad =
new PAD( footprint.get() );
210 footprint->Add(
pad );
211 board->
Add( footprint.release() );
215 BOOST_CHECK( livePad->
m_Uuid == newId );
228 auto shape = std::make_unique<PCB_SHAPE>( board );
233 board->
Add( shape.release() );
235 const_cast<KIID&
>( liveShape->
m_Uuid ) = newId;
250 auto footprint = std::make_unique<FOOTPRINT>( board );
251 FOOTPRINT* liveFootprint = footprint.get();
254 auto shape = std::make_unique<PCB_SHAPE>( board );
256 const KIID originalShapeId = liveShape->
m_Uuid;
258 board->
Add( footprint.release() );
259 board->
Add( shape.release() );
261 const_cast<KIID&
>( liveShape->
m_Uuid ) = claimedId;
264 BOOST_CHECK( liveFootprint->
m_Uuid == claimedId );
265 BOOST_CHECK( liveShape->
m_Uuid != claimedId );
266 BOOST_CHECK( liveShape->
m_Uuid != originalShapeId );
268 BOOST_CHECK( board->
ResolveItem( originalShapeId,
true ) ==
nullptr );
286 auto footprint = std::make_unique<FOOTPRINT>( board );
287 auto pad =
new PAD( footprint.get() );
288 pad->SetNumber(
"1" );
290 const KIID padId =
pad->m_Uuid;
291 footprint->Add(
pad );
293 FOOTPRINT* liveFootprint = footprint.get();
294 board->
Add( footprint.release() );
307 BOOST_CHECK( !staleEntrySurvived );
320 table->AddCell( cell );
325 const KIID cellId = cell->m_Uuid;
342 auto* footprint =
new FOOTPRINT( &board );
346 table->AddCell( cell );
348 board.
Add( footprint );
361 for(
int i = 0; i < 20000; i++ )
365 for(
int j = 0; j < 4; j++ )
368 board.
Add( footprint );
373 for(
int j = 0; j < 20; j++ )
376 auto start = std::chrono::steady_clock::now();
378 for(
int i = 0; i < 300; i++ )
381 std::chrono::duration<double> elapsed = std::chrono::steady_clock::now() - start;
383 BOOST_CHECK_LT( elapsed.count(), 5.0 );
394 auto*
pad =
new PAD(
nullptr );
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 ClearItemByIdCache()
void RebindItemUuid(BOARD_ITEM &aItem, const KIID &aNewId)
Rebind the UUID of an attached item and keep the item-by-id cache coherent.
void UncacheItemSubtreeById(const BOARD_ITEM &aItem)
Uncache an item and its children.
int RepairDuplicateItemUuids()
Rebind duplicate attached-item UUIDs so each live board item has a unique ID.
bool IsItemIndexedById(const BOARD_ITEM *aItem) const
Return true if aItem is currently indexed.
BOARD_ITEM * ResolveItem(const KIID &aID, bool aAllowNullptrReturn=false) const
KICAD_T Type() const
Returns the type of object.
std::vector< FAB_LAYER_COLOR > dummy
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_CASE(ResolveItemIdentityCachePurgedOnDestruction)
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