KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_eagle_binary_import.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.TXT for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
28
32
34
35#include <board.h>
36#include <footprint.h>
37#include <netinfo.h>
38#include <pcb_track.h>
39
40#include <wx/filename.h>
41
42
44{
46
47 BOARD* loadBoard( const std::string& aRelPath )
48 {
49 std::string dataPath = KI_TEST::GetPcbnewTestDataDir() + aRelPath;
50
51 if( !wxFileName::FileExists( dataPath ) )
52 {
53 BOOST_TEST_MESSAGE( "no real binary Eagle sample available at " + dataPath + "; load test skipped" );
54 return nullptr;
55 }
56
57 PCB_IO_EAGLE eaglePlugin;
58
59 // The binary format is identified by content, never by extension.
60 BOOST_CHECK( eaglePlugin.CanReadBoard( dataPath ) );
61
62 BOARD* board = nullptr;
63
64 try
65 {
66 board = eaglePlugin.LoadBoard( dataPath, nullptr, nullptr );
67 }
68 catch( const IO_ERROR& e )
69 {
70 BOOST_FAIL( "IO_ERROR loading binary Eagle board: " + e.What().ToStdString() );
71 }
72 catch( const std::exception& e )
73 {
74 BOOST_FAIL( std::string( "Exception loading binary Eagle board: " ) + e.what() );
75 }
76
77 return board;
78 }
79};
80
81
82BOOST_FIXTURE_TEST_SUITE( EagleBinaryImport, EAGLE_BINARY_IMPORT_FIXTURE )
83
84
85
90BOOST_AUTO_TEST_CASE( LoadBinaryV4V5 )
91{
92 std::unique_ptr<BOARD> board( loadBoard( "plugins/eagle_binary/blink1_b1a.brd" ) );
93
94 if( !board )
95 return;
96
97 BOOST_CHECK_GT( board->Footprints().size(), 0u );
98 BOOST_CHECK_GT( board->Tracks().size(), 0u );
99 BOOST_CHECK_GT( board->GetNetInfo().GetNetCount(), 1u );
100}
101
102
108BOOST_AUTO_TEST_CASE( LoadBinaryV3 )
109{
110 std::unique_ptr<BOARD> board( loadBoard( "plugins/eagle_binary/blink1_v1a.brd" ) );
111
112 if( !board )
113 return;
114
115 BOOST_CHECK_GT( board->Footprints().size(), 0u );
116 BOOST_CHECK_GT( board->Tracks().size(), 0u );
117}
118
119
General utilities for PCB file IO for QA programs.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:323
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
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.
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
BOARD * loadBoard(const std::string &aRelPath)
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_TEST_MESSAGE("\n=== Real-World Polygon PIP Benchmark ===\n"<< formatTable(table))