20#include <boost/test/unit_test.hpp>
39constexpr int MM = 1000000;
42std::unique_ptr<BOARD> loadBoard(
const char* aBoardFile )
45 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
47 board->BuildConnectivity();
53std::set<BOARD_CONNECTED_ITEM*> chainItems(
BOARD* aBoard,
const wxString& aChain )
55 std::set<BOARD_CONNECTED_ITEM*> items;
59 if( t->GetNet() && t->GetNet()->GetNetChain() == aChain )
65 for(
PAD* p : fp->Pads() )
67 if( p->GetNet() && p->GetNet()->GetNetChain() == aChain )
79void tagChain(
BOARD* aBoard,
const wxString& aChain,
const wxString& aFirstFpRef,
80 const wxString& aLastFpRef )
84 if( n && n->GetNetname().StartsWith( wxS(
"/NET_" ) ) )
85 n->SetNetChain( aChain );
93 if( fp->GetReference() == aFirstFpRef && !fp->Pads().empty() )
94 termA = fp->Pads().front();
96 if( fp->GetReference() == aLastFpRef && !fp->Pads().empty() )
97 termB = fp->Pads().back();
103 if( n && n->GetNetChain() == aChain )
104 n->SetTerminalPad( 0, termA );
110 if( n && n->GetNetChain() == aChain )
111 n->SetTerminalPad( 1, termB );
127 auto board = loadBoard(
"net_chains/chain_topology_trunk.kicad_pcb" );
128 tagChain( board.get(), wxS(
"SIG" ), wxS(
"FP_START" ), wxS(
"FP_END" ) );
130 auto items = chainItems( board.get(), wxS(
"SIG" ) );
137 BOOST_CHECK( topo.
Stubs().empty() );
144 auto board = loadBoard(
"net_chains/chain_topology_t_stub.kicad_pcb" );
145 tagChain( board.get(), wxS(
"TSIG" ), wxS(
"FP_START" ), wxS(
"FP_END" ) );
147 auto items = chainItems( board.get(), wxS(
"TSIG" ) );
151 BOOST_REQUIRE_EQUAL( topo.
Stubs().size(), 1u );
157 BOOST_CHECK_CLOSE( stub.
length, 5.0 *
MM, 5.0 );
167 auto board = loadBoard(
"net_chains/chain_topology_missing_terminal.kicad_pcb" );
171 if( n && n->GetNetname().StartsWith( wxS(
"/NET_" ) ) )
172 n->SetNetChain( wxS(
"MISSING" ) );
175 PAD* termA = board->Footprints().empty()
177 : board->Footprints().front()->Pads().empty()
179 : board->Footprints().front()->Pads().front();
184 if( n && n->GetNetChain() == wxS(
"MISSING" ) )
185 n->SetTerminalPad( 0, termA );
188 auto items = chainItems( board.get(), wxS(
"MISSING" ) );
199 auto board = loadBoard(
"net_chains/chain_topology_disconnected.kicad_pcb" );
200 tagChain( board.get(), wxS(
"DISC" ), wxS(
"FP_START" ), wxS(
"FP_END" ) );
202 auto items = chainItems( board.get(), wxS(
"DISC" ) );
213 auto board = loadBoard(
"net_chains/chain_topology_cycle.kicad_pcb" );
214 tagChain( board.get(), wxS(
"LOOP" ), wxS(
"FP_START" ), wxS(
"FP_END" ) );
216 auto items = chainItems( board.get(), wxS(
"LOOP" ) );
General utilities for PCB file IO for QA programs.
Information pertinent to a Pcbnew printed circuit board.
const NETINFO_LIST & GetNetInfo() const
const FOOTPRINTS & Footprints() const
const TRACKS & Tracks() const
Build a topological view of a single named net chain's routed copper.
const std::vector< STUB > & Stubs() const
double TrunkLength() const
Handle the data for a net.
A #PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
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 ...
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE(TopologyTreeOnSimpleTrunk)
BOOST_AUTO_TEST_SUITE_END()
static const long long MM
BOOST_CHECK_EQUAL(result, "25.4")