76std::unique_ptr<BOARD>
createBoard(
const std::vector<std::vector<ItemType>>& spec )
78 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
79 std::vector<BOARD_ITEM*> items;
85 textItem->
SetText( wxString::Format(
_(
"some text-%d" ), idx ) );
89 board->Add( textItem );
91 items.push_back( textItem );
101 wxString
name = wxString::Format(
_(
"group-%d" ),
107 items.push_back( gr );
110 std::bitset<NUM_ITEMS> used;
115 int groupIdx =
GROUP0 + offset;
119 if( offset < spec.size() )
121 const std::vector<ItemType>& groupSpec = spec[offset];
125 used.set(
static_cast<size_t>( item ) );
126 group->AddItem( items[item] );
129 BOOST_CHECK_EQUAL(
group->GetItems().size(), groupSpec.size() );
132 else if( groupIdx !=
REMOVED_GROUP && used.test( groupIdx ) )
156 BOOST_TEST_CHECKPOINT(
"Returning fresh board" );
167 const std::unordered_set<BOARD_ITEM*>& items1 = group1.
GetItems();
168 const std::unordered_set<BOARD_ITEM*>& items2 = group2.
GetItems();
170 BOOST_CHECK_EQUAL( items1.size(), items2.size() );
177 return elem->m_Uuid.AsString() == item1->m_Uuid.AsString();
180 auto item2 = std::find_if( items2.begin(), items2.end(), cmp );
182 BOOST_CHECK( item2 != items2.end() );
190 BOOST_CHECK_EQUAL( groups1.size(), groups2.size() );
196 return elem->m_Uuid.AsString() == group1->m_Uuid.AsString();
199 auto group2 = std::find_if( groups2.begin(), groups2.end(), cmp );
201 BOOST_CHECK( group2 != groups2.end() );
214 std::unique_ptr<BOARD> board1 =
createBoard( spec );
215 auto path = std::filesystem::temp_directory_path() /
"group_saveload_tst.kicad_pcb";
250 BOOST_CHECK_EQUAL( board1->GroupsSanityCheck(),
"Cycle detected in group membership" );
255 BOOST_CHECK_EQUAL( board1->GroupsSanityCheck(),
"Cycle detected in group membership" );
258 board1.reset(
nullptr );
263 board1.reset(
nullptr );
Construction utilities for PCB tests.
General utilities for PCB file IO for QA programs.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual void SetText(const wxString &aText)
wxString AsString() const
A set of BOARD_ITEMs (i.e., without duplicates).
std::unordered_set< BOARD_ITEM * > & GetItems()
void SetName(const wxString &aName)
BOOST_AUTO_TEST_CASE(HealthyGroups)
void testGroupEqual(const PCB_GROUP &group1, const PCB_GROUP &group2)
void testGroupsEqual(const GROUPS &groups1, const GROUPS &groups2)
std::unique_ptr< BOARD > createBoard(const std::vector< std::vector< ItemType > > &spec)
static PCB_GROUP * s_removedGroup
void testSaveLoad(const std::vector< std::vector< ItemType > > &spec)
static PCB_TEXT * s_removedText
std::unique_ptr< BOARD > ReadBoardFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
Read a board from a file, or another stream, as appropriate.
void DumpBoardToFile(BOARD &board, const std::string &aFilename)
Utility function to simply write a Board out to a file.
Class to handle a set of BOARD_ITEMs.
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()