20#include <boost/test/unit_test.hpp>
32 wxString
GetClass()
const override {
return wxT(
"TEST_EDA_ITEM"); }
55 if( aTestItem->
Type() == type )
68 return INSPECT_RESULT::CONTINUE;
86 default: os <<
"UNKNOWN";
break;
108 collector.
Append( &item );
121 collector.
Append( &item1 );
122 collector.
Append( &item2 );
123 collector.
Append( &item3 );
135 collector.
Append(
nullptr );
147 collector.
Append( &item1 );
148 collector.
Append( &item2 );
163 collector.
Append( &item1 );
164 collector.
Append( &item2 );
165 collector.
Append( &item3 );
180 collector.
Append( &item1 );
181 collector.
Append( &item2 );
195 collector.
Append( &item1 );
196 collector.
Append( &item2 );
211 collector.
Append( &item1 );
212 collector.
Append( &item2 );
213 collector.
Append( &item3 );
215 collector.
Remove( &item2 );
229 collector.
Append( &item1 );
230 collector.
Append( &item2 );
232 collector.
Remove( &item3 );
244 collector.
Append( &item1 );
245 collector.
Append( &item1 );
246 collector.
Append( &item1 );
248 collector.
Remove( &item1 );
260 collector.
Append( &item1 );
261 collector.
Append( &item2 );
262 collector.
Append( &item3 );
279 collector.
Append( &item1 );
280 collector.
Append( &item2 );
281 collector.
Append( &item3 );
298 collector.
Append( &item1 );
299 collector.
Append( &item2 );
314 collector.
Append( &item1 );
315 collector.
Append( &item2 );
316 collector.
Append( &item3 );
338 collector.
Append( &item1 );
354 collector.
Append( &item1 );
355 collector.
Append( &item2 );
366 collector.
Append( &item1 );
386 collector.
Append( &item1 );
387 collector.
Append( &item2 );
389 BOOST_CHECK( collector.
HasItem( &item1 ) );
390 BOOST_CHECK( collector.
HasItem( &item2 ) );
400 collector.
Append( &item1 );
401 collector.
Append( &item2 );
403 BOOST_CHECK( !collector.
HasItem( &item3 ) );
411 collector.
Append( &item1 );
412 collector.
Append(
nullptr );
414 BOOST_CHECK( collector.
HasItem(
nullptr ) );
422 BOOST_CHECK( !collector.
HasItem( &item1 ) );
432 collector.
Append( &item1 );
433 collector.
Append( &item2 );
434 collector.
Append( &item3 );
477 collector.
Append( &item1 );
478 collector.
Append( &item2 );
479 collector.
Append( &item3 );
481 std::vector<EDA_ITEM*> items;
482 for(
auto iter = collector.
begin(); iter != collector.
end(); ++iter )
484 items.push_back( *iter );
499 collector.
Append( &item1 );
500 collector.
Append( &item2 );
502 std::vector<EDA_ITEM*> items;
505 items.push_back( item );
518 collector.
Append( &item1 );
520 const COLLECTOR& constCollector = collector;
521 std::vector<const EDA_ITEM*> items;
523 for(
auto iter = constCollector.
begin(); iter != constCollector.
end(); ++iter )
525 items.push_back( *iter );
554 collector.
Inspect( &item1,
nullptr );
555 collector.
Inspect( &item2,
nullptr );
556 collector.
Inspect( &item3,
nullptr );
559 BOOST_CHECK( collector.
HasItem( &item1 ) );
560 BOOST_CHECK( collector.
HasItem( &item2 ) );
561 BOOST_CHECK( !collector.
HasItem( &item3 ) );
573 collector.
Append( &item1 );
574 collector.
Append( &item2 );
575 collector.
Append( &item3 );
576 collector.
Append( &item4 );
586 collector.
Remove( &item1 );
595 BOOST_CHECK( !collector.
HasItem( &item1 ) );
596 BOOST_CHECK( collector.
HasItem( &item2 ) );
597 BOOST_CHECK( collector.
HasItem( &item3 ) );
598 BOOST_CHECK( collector.
HasItem( &item4 ) );
An abstract class that will find and hold all the objects according to an inspection done by the Insp...
void Transfer(int aIndex)
Move the item at aIndex (first position is 0) to the backup list.
void Empty()
Clear the list.
int GetCount() const
Return the number of objects in the list.
bool HasItem(const EDA_ITEM *aItem) const
Tests if aItem has already been collected.
void SetScanTypes(const std::vector< KICAD_T > &aTypes)
Record the list of KICAD_T types to consider for collection by the Inspect() function.
void SetRefPos(const VECTOR2I &aRefPos)
int CountType(KICAD_T aType)
Count the number of items matching aType.
std::vector< KICAD_T > m_scanTypes
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
bool HasAdditionalItems()
Test if the collector has heuristic backup items.
void Combine()
Re-combine the backup list into the main list of the collector.
void Append(EDA_ITEM *item)
Add an item to the end of the list.
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
INSPECT_RESULT Inspect(EDA_ITEM *aTestItem, void *aTestData) override
void SetShouldCollect(bool aShouldCollect)
int GetInspectCalls() const
TEST_EDA_ITEM(KICAD_T aType)
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
wxString GetClass() const override
Return the class name.
std::ostream & operator<<(std::ostream &aStream, const EDA_TEXT &aText)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_CHECK_EQUAL(ret, c.m_exp_result)
BOOST_AUTO_TEST_CASE(Constructor_DefaultValues)
BOOST_AUTO_TEST_SUITE_END()
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)