20#include <boost/test/unit_test.hpp>
39constexpr int MM = 1000000;
42std::unique_ptr<BOARD> loadBoard(
const char* aBoardFile )
46 board->BuildConnectivity();
52std::set<BOARD_CONNECTED_ITEM*> chainItems(
BOARD* aBoard,
const wxString& aChain )
54 std::set<BOARD_CONNECTED_ITEM*> items;
58 if( t->GetNet() && t->GetNet()->GetNetChain() == aChain )
64 for(
PAD* p : fp->Pads() )
66 if( p->GetNet() && p->GetNet()->GetNetChain() == aChain )
78void tagChain(
BOARD* aBoard,
const wxString& aChain,
const wxString& aFirstFpRef,
79 const wxString& aLastFpRef )
83 if( n && n->GetNetname().StartsWith( wxS(
"/NET_" ) ) )
84 n->SetNetChain( aChain );
92 if( fp->GetReference() == aFirstFpRef && !fp->Pads().empty() )
93 termA = fp->Pads().front();
95 if( fp->GetReference() == aLastFpRef && !fp->Pads().empty() )
96 termB = fp->Pads().back();
102 if( n && n->GetNetChain() == aChain )
103 n->SetTerminalPad( 0, termA );
109 if( n && n->GetNetChain() == aChain )
110 n->SetTerminalPad( 1, termB );
126 auto board = loadBoard(
"net_chains/chain_topology_trunk.kicad_pcb" );
127 tagChain( board.get(), wxS(
"SIG" ), wxS(
"FP_START" ), wxS(
"FP_END" ) );
129 auto items = chainItems( board.get(), wxS(
"SIG" ) );
136 BOOST_CHECK( topo.
Stubs().empty() );
143 auto board = loadBoard(
"net_chains/chain_topology_t_stub.kicad_pcb" );
144 tagChain( board.get(), wxS(
"TSIG" ), wxS(
"FP_START" ), wxS(
"FP_END" ) );
146 auto items = chainItems( board.get(), wxS(
"TSIG" ) );
150 BOOST_REQUIRE_EQUAL( topo.
Stubs().size(), 1u );
156 BOOST_CHECK_CLOSE( stub.
length, 5.0 *
MM, 5.0 );
166 auto board = loadBoard(
"net_chains/chain_topology_missing_terminal.kicad_pcb" );
170 if( n && n->GetNetname().StartsWith( wxS(
"/NET_" ) ) )
171 n->SetNetChain( wxS(
"MISSING" ) );
174 PAD* termA = board->Footprints().empty()
176 : board->Footprints().front()->Pads().empty()
178 : board->Footprints().front()->Pads().front();
183 if( n && n->GetNetChain() == wxS(
"MISSING" ) )
184 n->SetTerminalPad( 0, termA );
187 auto items = chainItems( board.get(), wxS(
"MISSING" ) );
198 auto board = loadBoard(
"net_chains/chain_topology_disconnected.kicad_pcb" );
199 tagChain( board.get(), wxS(
"DISC" ), wxS(
"FP_START" ), wxS(
"FP_END" ) );
201 auto items = chainItems( board.get(), wxS(
"DISC" ) );
212 auto board = loadBoard(
"net_chains/chain_topology_cycle.kicad_pcb" );
213 tagChain( board.get(), wxS(
"LOOP" ), wxS(
"FP_START" ), wxS(
"FP_END" ) );
215 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.
std::unique_ptr< BOARD > LoadBoard(const wxString &aFileName, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr)
Load information from some input file format that this PCB_IO implementation knows about into new BOA...
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")