20#include <boost/test/unit_test.hpp>
44 void Load(
const wxString& aFixtureName )
49 m_schematic->BuildSheetListSortedByPageNumbers(),
true );
59 for(
const auto& sig :
m_schematic->ConnectionGraph()->GetPotentialNetChains() )
82 Load( wxS(
"net_chains_four_nets" ) );
85 BOOST_REQUIRE_MESSAGE(
chain,
"Fixture must contain at least one inferred chain" );
86 BOOST_REQUIRE_EQUAL(
chain->GetNets().size(), 4u );
89 const std::vector<wxString>& ordered =
chain->GetOrderedNets( graph );
92 BOOST_REQUIRE_EQUAL( ordered.size(),
chain->GetNets().size() );
94 std::set<wxString> seen( ordered.begin(), ordered.end() );
95 BOOST_CHECK( seen ==
chain->GetNets() );
98 wxString termA =
chain->GetTerminalNetName( 0, graph );
99 wxString termB =
chain->GetTerminalNetName( 1, graph );
111 Load( wxS(
"net_chains_four_nets" ) );
117 std::vector<wxString> first =
chain->GetOrderedNets( graph );
118 std::vector<wxString> second =
chain->GetOrderedNets( graph );
120 BOOST_CHECK( first == second );
128 Load( wxS(
"net_chains_four_nets" ) );
134 const std::vector<wxString> before =
chain->GetOrderedNets( graph );
135 const wxString sentinel = wxS(
"__ordered_nets_test_sentinel__" );
137 chain->AddNet( sentinel );
139 const std::vector<wxString>& after =
chain->GetOrderedNets( graph );
141 BOOST_CHECK( std::find( after.begin(), after.end(), sentinel ) != after.end() );
142 BOOST_CHECK_GT( after.size(), before.size() );
155 Load( wxS(
"net_chains_branching_longer" ) );
159 BOOST_REQUIRE_GE(
chain->GetNets().size(), 3u );
162 const std::vector<wxString>& ordered =
chain->GetOrderedNets( graph );
164 BOOST_REQUIRE_EQUAL( ordered.size(),
chain->GetNets().size() );
166 std::set<wxString> seen( ordered.begin(), ordered.end() );
167 BOOST_CHECK( seen ==
chain->GetNets() );
169 wxString termA =
chain->GetTerminalNetName( 0, graph );
170 wxString termB =
chain->GetTerminalNetName( 1, graph );
176 auto itB = std::find( ordered.begin(), ordered.end(), termB );
177 BOOST_CHECK( itB != ordered.end() );
186 Load( wxS(
"net_chains_four_nets" ) );
191 const std::vector<wxString>&
empty =
chain->GetOrderedNets(
nullptr );
192 BOOST_CHECK(
empty.empty() );
195 const std::vector<wxString>& populated =
chain->GetOrderedNets( m_schematic->ConnectionGraph() );
196 BOOST_CHECK( !populated.empty() );
205 const std::vector<wxString>& first = bare.
GetOrderedNets(
nullptr );
206 BOOST_CHECK( first.empty() );
208 bare.
AddNet( wxS(
"A" ) );
209 bare.
AddNet( wxS(
"B" ) );
212 const std::vector<wxString>& second = bare.
GetOrderedNets(
nullptr );
213 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")