21#include <boost/test/unit_test.hpp>
45 void Load(
const wxString& aFixtureName )
50 m_schematic->BuildSheetListSortedByPageNumbers(),
true );
60 for(
const auto& sig :
m_schematic->ConnectionGraph()->GetPotentialNetChains() )
83 Load( wxS(
"net_chains_four_nets" ) );
86 BOOST_REQUIRE_MESSAGE(
chain,
"Fixture must contain at least one inferred chain" );
87 BOOST_REQUIRE_EQUAL(
chain->GetNets().size(), 4u );
90 const std::vector<wxString>& ordered =
chain->GetOrderedNets( graph );
93 BOOST_REQUIRE_EQUAL( ordered.size(),
chain->GetNets().size() );
95 std::set<wxString> seen( ordered.begin(), ordered.end() );
96 BOOST_CHECK( seen ==
chain->GetNets() );
99 wxString termA =
chain->GetTerminalNetName( 0, graph );
100 wxString termB =
chain->GetTerminalNetName( 1, graph );
112 Load( wxS(
"net_chains_four_nets" ) );
118 std::vector<wxString> first =
chain->GetOrderedNets( graph );
119 std::vector<wxString> second =
chain->GetOrderedNets( graph );
121 BOOST_CHECK( first == second );
129 Load( wxS(
"net_chains_four_nets" ) );
135 const std::vector<wxString> before =
chain->GetOrderedNets( graph );
136 const wxString sentinel = wxS(
"__ordered_nets_test_sentinel__" );
138 chain->AddNet( sentinel );
140 const std::vector<wxString>& after =
chain->GetOrderedNets( graph );
142 BOOST_CHECK( std::find( after.begin(), after.end(), sentinel ) != after.end() );
143 BOOST_CHECK_GT( after.size(), before.size() );
156 Load( wxS(
"net_chains_branching_longer" ) );
160 BOOST_REQUIRE_GE(
chain->GetNets().size(), 3u );
163 const std::vector<wxString>& ordered =
chain->GetOrderedNets( graph );
165 BOOST_REQUIRE_EQUAL( ordered.size(),
chain->GetNets().size() );
167 std::set<wxString> seen( ordered.begin(), ordered.end() );
168 BOOST_CHECK( seen ==
chain->GetNets() );
170 wxString termA =
chain->GetTerminalNetName( 0, graph );
171 wxString termB =
chain->GetTerminalNetName( 1, graph );
177 auto itB = std::find( ordered.begin(), ordered.end(), termB );
178 BOOST_CHECK( itB != ordered.end() );
187 Load( wxS(
"net_chains_four_nets" ) );
192 const std::vector<wxString>&
empty =
chain->GetOrderedNets(
nullptr );
193 BOOST_CHECK(
empty.empty() );
196 const std::vector<wxString>& populated =
chain->GetOrderedNets( m_schematic->ConnectionGraph() );
197 BOOST_CHECK( !populated.empty() );
206 const std::vector<wxString>& first = bare.
GetOrderedNets(
nullptr );
207 BOOST_CHECK( first.empty() );
209 bare.
AddNet( wxS(
"A" ) );
210 bare.
AddNet( wxS(
"B" ) );
213 const std::vector<wxString>& second = bare.
GetOrderedNets(
nullptr );
214 BOOST_CHECK( second.empty() );
KICAD_PLUGIN_EXPORT SCENEGRAPH * Load(char const *aFileName)
Read a model file and creates a generic display structure.
Calculate the connectivity of a schematic and generates netlists.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
A net chain is a collection of nets that are connected together through passive components.
const std::set< wxString > & GetNets() const
const std::vector< wxString > & GetOrderedNets(CONNECTION_GRAPH *aGraph) const
Return the chain's member nets ordered from terminal pin A's net to terminal pin B's net along the sh...
void AddNet(const wxString &aNet)
static bool empty(const wxTextEntryBase *aCtrl)
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
std::vector< FAB_LAYER_COLOR > dummy
void Load(const wxString &aFixtureName)
SETTINGS_MANAGER m_settingsManager
std::unique_ptr< SCHEMATIC > m_schematic
SCH_NETCHAIN * FindLargestPotentialChain() const
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(LinearChainCoversEveryMemberWithTerminalsAtEnds)
const SHAPE_LINE_CHAIN chain
BOOST_CHECK_EQUAL(result, "25.4")