44#include <wx/filename.h>
55 if( !wxFileName::FileExists( dataPath ) )
57 BOOST_TEST_MESSAGE(
"no real binary Eagle sample available at " + dataPath +
"; load test skipped" );
66 BOARD* board =
nullptr;
70 board = eaglePlugin.
LoadBoard( dataPath,
nullptr,
nullptr );
74 BOOST_FAIL(
"IO_ERROR loading binary Eagle board: " + e.
What().ToStdString() );
76 catch(
const std::exception& e )
78 BOOST_FAIL( std::string(
"Exception loading binary Eagle board: " ) + e.
what() );
86 std::vector<ZONE*> pours;
90 if( !zone->GetIsRuleArea() &&
IsCopperLayer( zone->GetFirstLayer() ) )
91 pours.push_back( zone );
109 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/blink1_b1a.brd" ) );
114 BOOST_CHECK_GT( board->Footprints().size(), 0u );
115 BOOST_CHECK_GT( board->Tracks().size(), 0u );
116 BOOST_CHECK_GT( board->GetNetInfo().GetNetCount(), 1u );
127 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/blink1_v1a.brd" ) );
132 BOOST_CHECK_GT( board->Footprints().size(), 0u );
133 BOOST_CHECK_GT( board->Tracks().size(), 0u );
145 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/rocketgps.brd" ) );
150 BOOST_CHECK_GT( board->Footprints().size(), 0u );
151 BOOST_CHECK_GT( board->Tracks().size(), 0u );
152 BOOST_CHECK_GT( board->GetNetInfo().GetNetCount(), 1u );
165 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/boomchak.brd" ) );
170 BOOST_CHECK_GT( board->Footprints().size(), 0u );
171 BOOST_CHECK_GT( board->Tracks().size(), 0u );
172 BOOST_CHECK_GT( board->GetNetInfo().GetNetCount(), 1u );
176 for(
PCB_TRACK* track : board->Tracks() )
177 BOOST_CHECK( track->GetNet() !=
nullptr );
188 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/turnemoff.brd" ) );
193 BOOST_CHECK_GT( board->Footprints().size(), 0u );
194 BOOST_CHECK_GT( board->Tracks().size(), 0u );
208 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/issue24612_nova_usbbox.brd" ) );
213 BOOST_CHECK_GT( board->Footprints().size(), 0u );
214 BOOST_CHECK_GT( board->Tracks().size(), 0u );
216 std::set<wxString> texts;
221 texts.insert(
text->GetText() );
224 BOOST_CHECK( texts.count( wxS(
"ASTROELEKTRONIK" ) ) );
225 BOOST_CHECK( texts.count( wxS(
"Nova+ USB-Box" ) ) );
239 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/Sigma2_e.brd" ) );
244 BOOST_CHECK_GT( board->Footprints().size(), 0u );
245 BOOST_CHECK_GT( board->Tracks().size(), 0u );
246 BOOST_CHECK_GT( board->GetNetInfo().GetNetCount(), 1u );
259 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/boomchak.brd" ) );
264 std::map<int, double> ledRot;
266 for(
FOOTPRINT* fp : board->Footprints() )
270 if( fp->GetReference().StartsWith( wxS(
"LED" ) ) && fp->GetReference().Mid( 3 ).ToLong( &n ) )
271 ledRot[(int) n] = fp->GetOrientation().AsDegrees();
274 for(
int n = 1; n < 16; n++ )
276 BOOST_REQUIRE_MESSAGE( ledRot.count( n ) && ledRot.count( n + 1 ),
277 "expected ring footprints LED" << n <<
" and LED" << ( n + 1 ) );
279 double step = ledRot[n + 1] - ledRot[n];
281 while( step > 180.0 )
284 while( step <= -180.0 )
287 BOOST_CHECK_CLOSE( step, 22.5, 0.5 );
303 auto invalidLayerItems = [](
BOARD* board )
310 count += bad( item->GetLayer() );
312 for(
PCB_TRACK* track : board->Tracks() )
313 count += bad( track->GetLayer() );
315 for(
FOOTPRINT* fp : board->Footprints() )
317 for(
BOARD_ITEM* item : fp->GraphicalItems() )
318 count += bad( item->GetLayer() );
324 auto ruleAreas = [](
BOARD* board )
328 for(
ZONE* zone : board->Zones() )
329 count += zone->GetIsRuleArea();
334 for(
const char* relPath : {
"plugins/eagle_binary/boomchak.brd",
335 "plugins/eagle_binary/turnemoff.brd" } )
337 std::unique_ptr<BOARD> board( loadBoard( relPath ) );
348 std::unique_ptr<BOARD> turnemoff( loadBoard(
"plugins/eagle_binary/turnemoff.brd" ) );
351 BOOST_CHECK_GT( ruleAreas( turnemoff.get() ), 500 );
366 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/blink1_b1a.brd" ) );
371 auto footprintTexts = [&]()
373 std::set<wxString> texts;
375 for(
FOOTPRINT* fp : board->Footprints() )
377 texts.insert( fp->Value().GetText() );
379 for(
BOARD_ITEM* item : fp->GraphicalItems() )
382 texts.insert(
text->GetText() );
389 BOOST_CHECK( !footprintTexts.count( wxS(
"${VALU}" ) ) );
390 BOOST_CHECK( !footprintTexts.count( wxS(
">VALU" ) ) );
403 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/boomchak.brd" ) );
408 std::vector<ZONE*> pours = copperPours( board.get() );
410 BOOST_REQUIRE_GE( pours.size(), 2u );
414 for(
ZONE* zone : pours )
417 BOOST_CHECK_GE( zone->GetNumCorners(), 3 );
430 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/issue24812_vertice_error.brd" ) );
435 BOOST_CHECK_GE( copperPours( board.get() ).size(), 2u );
451 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/issue24827_brenner57e.brd" ) );
456 BOOST_REQUIRE_GT( board->Footprints().size(), 0u );
458 int padsWithNumber = 0;
459 int padsWithoutNumber = 0;
460 int multiPinPartsWithDistinctNets = 0;
462 for(
FOOTPRINT* fp : board->Footprints() )
466 for(
PAD*
pad : fp->Pads() )
468 if(
pad->GetNumber().IsEmpty() )
473 nets.insert(
pad->GetNetCode() );
476 if( fp->Pads().size() > 1 && nets.size() > 1 )
477 multiPinPartsWithDistinctNets++;
482 BOOST_CHECK_GT( padsWithNumber, 0 );
487 BOOST_CHECK_GT( multiPinPartsWithDistinctNets, 0 );
502 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/issue24827_brenner57e.brd" ) );
507 auto shapeOf = [&](
const wxString& aRef ) ->
PAD_SHAPE
509 for(
FOOTPRINT* fp : board->Footprints() )
511 if( fp->GetReference() == aRef && !fp->Pads().empty() )
538 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/issue24827_brenner57e.brd" ) );
543 auto bodyArcs = [&](
const wxString& aRef )
545 std::vector<PCB_SHAPE*> arcs;
547 for(
FOOTPRINT* fp : board->Footprints() )
549 if( fp->GetReference() != aRef )
552 for(
BOARD_ITEM* item : fp->GraphicalItems() )
557 arcs.push_back( shape );
566 for(
const wxString& ref : { wxS(
"Q2" ), wxS(
"IC3" ) } )
568 std::vector<PCB_SHAPE*> arcs = bodyArcs( ref );
569 BOOST_REQUIRE_GT( arcs.size(), 1u );
575 int dist = ( arc->GetCenter() -
center ).EuclideanNorm();
577 ref <<
" silk arc center is " << dist / 1e6 <<
" mm off the body center" );
constexpr EDA_IU_SCALE pcbIUScale
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...
Information pertinent to a Pcbnew printed circuit board.
const ZONES & Zones() const
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
virtual const char * what() const override
std::exception interface, returned as UTF-8
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
Works with Eagle 6.x XML board files and footprints to implement the Pcbnew #PLUGIN API or a portion ...
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PCB_IO can read the specified board file.
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Handle a list of polygons defining a copper zone.
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
PCB_LAYER_ID
A quick note on layer IDs:
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
BOARD * loadBoard(const std::string &aRelPath)
static std::vector< ZONE * > copperPours(BOARD *aBoard)
EAGLE_BINARY_IMPORT_FIXTURE()
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_CASE(LoadBinaryV4V5)
Load a v4/v5 binary board (magic 0x10 0x00) which also carries the trailing free-text and DRC section...
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
BOOST_TEST_MESSAGE("\n=== Real-World Polygon PIP Benchmark ===\n"<< formatTable(table))
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I