47 std::unique_ptr<SCHEMATIC> schematic;
49 schematic->RebuildConnectivity();
50 const wxString
name = wxS(
"/S0.BOOT.SDA" );
56 size_t directCount = 0;
57 size_t expandedCount = 0;
59 for(
const auto& [
path, items] : direct )
60 directCount += items.size();
62 for(
const auto& [
path, items] : withBuses )
64 expandedCount += items.size();
65 BOOST_CHECK_EQUAL( std::set<SCH_ITEM*>( items.begin(), items.end() ).size(), items.size() );
68 BOOST_REQUIRE_GT( expandedCount, directCount );
69 const auto root = schematic->Hierarchy().front();
70 std::optional<wxString> busName;
74 if(
static_cast<SCH_LABEL*
>( item )->GetText() == wxS(
"S0{ALIAS1}" ) )
75 busName = item->GetConnectionName( &root );
82 schematic->RebuildConnectivity();
87 BOOST_CHECK( names == legacyNames );
88 BOOST_CHECK( std::ranges::find( names,
name ) != names.end() );
96 std::unique_ptr<SCHEMATIC> schematic;
98 auto* original = schematic->GetTopLevelSheet();
99 auto copy = std::unique_ptr<SCH_SHEET>(
static_cast<SCH_SHEET*
>( original->Clone() ) );
101 copy->SetName( wxS(
"Second" ) );
102 schematic->AddTopLevelSheet(
copy.release() );
103 const auto paths = schematic->Hierarchy();
104 BOOST_REQUIRE_EQUAL( paths.size(), 2u );
105 BOOST_REQUIRE( paths[0].LastScreen() == paths[1].LastScreen() );
110 auto* candidate =
static_cast<SCH_LABEL*
>( item );
112 if( candidate->GetText() == wxS(
"SIG" ) )
118 for(
bool backend : {
false,
true } )
121 schematic->RebuildConnectivity();
123 for(
const auto&
path : paths )
128 BOOST_REQUIRE_EQUAL(
result.size(), 1u );
129 BOOST_CHECK(
result.begin()->first.Path() ==
path.Path() );
130 const auto& items =
result.begin()->second;
131 BOOST_CHECK( std::ranges::find( items, label ) != items.end() );
141 std::unique_ptr<SCHEMATIC> schematic;
145 for(
bool backend : {
false,
true } )
148 schematic->RebuildConnectivity();
150 const wxString aliasName = wxS(
"/{MIXED_BUS}" );
151 const auto alias = query.
NetItems( aliasName,
true );
152 const auto expanded = query.
NetItems( wxS(
"/{FOO BAR HAM EGGS}" ),
true );
153 const auto direct = query.
NetItems( aliasName,
false );
155 BOOST_CHECK_GT( alias.size(), direct.size() );
156 BOOST_CHECK( alias == expanded );
159 BOOST_CHECK( alias == legacy );
170 std::unique_ptr<SCHEMATIC> schematic;
172 schematic->RebuildConnectivity();
173 const wxString
name = wxS(
"/S0.BOOT.SDA" );
175 const auto root = schematic->Hierarchy().front();
176 BOOST_REQUIRE_EQUAL(
expected.erase( root ), 1u );
178 root.LastScreen()->BumpConnectivityRevision();
181 const auto names = query.
NetNames();
182 BOOST_CHECK( std::ranges::find( names,
name ) != names.end() );
190 std::unique_ptr<SCHEMATIC> schematic;
192 auto* original = schematic->GetTopLevelSheet();
193 auto copy = std::unique_ptr<SCH_SHEET>(
static_cast<SCH_SHEET*
>( original->Clone() ) );
195 copy->SetName( wxS(
"Second" ) );
196 schematic->AddTopLevelSheet(
copy.release() );
197 const auto paths = schematic->Hierarchy();
198 BOOST_REQUIRE_EQUAL( paths.size(), 2u );
199 BOOST_REQUIRE( paths[0].LastScreen() == paths[1].LastScreen() );
204 if(
static_cast<SCH_GLOBALLABEL*
>( item )->GetText() == wxS(
"test_OK" ) )
210 for(
bool backend : {
false,
true } )
213 schematic->RebuildConnectivity();
217 BOOST_REQUIRE_EQUAL(
result.size(), 2u );
220 BOOST_CHECK(
result.at( paths[0] ) ==
result.at( paths[1] ) );
221 const auto& items =
result.at( paths[0] );
222 BOOST_CHECK( std::ranges::find( items, label ) != items.end() );
231 std::unique_ptr<SCHEMATIC> schematic;
233 schematic->RebuildConnectivity();
234 const auto root = schematic->Hierarchy().front();
239 if(
static_cast<SCH_LABEL*
>( item )->GetText() == wxS(
"S0{ALIAS1}" ) )
246 const std::vector<wxString> expectedSignals{ wxS(
"/S0.BOOT.SCL" ), wxS(
"/S0.BOOT.SDA" ) };
248 BOOST_CHECK( legacyQuery.
SignalNames( *busName ) == expectedSignals );
249 const auto expectedItems = legacyQuery.
NetItems( *busName,
true,
true );
250 const auto busItems = legacyQuery.
NetItems( *busName,
true );
253 schematic->ConnectionGraph()->Reset();
254 schematic->RebuildConnectivity();
256 BOOST_CHECK( query.
SignalNames( *busName ) == expectedSignals );
257 BOOST_CHECK( query.
NetItems( *busName,
true,
true ) == expectedItems );
258 BOOST_CHECK( query.
SignalNames( expectedSignals.front() )
259 == std::vector<wxString>{ expectedSignals.front() } );
267 std::unique_ptr<SCHEMATIC> schematic;
269 auto* original = schematic->GetTopLevelSheet();
270 auto copy = std::unique_ptr<SCH_SHEET>(
static_cast<SCH_SHEET*
>( original->Clone() ) );
272 copy->SetName( wxS(
"Second" ) );
273 schematic->AddTopLevelSheet(
copy.release() );
274 const auto paths = schematic->Hierarchy();
275 BOOST_REQUIRE_EQUAL( paths.size(), 2u );
279 auto* symbol =
static_cast<SCH_SYMBOL*
>( item );
280 symbol->
SetRef( &paths[1], symbol->GetRef( &paths[0] ) + wxS(
"0" ) );
283 schematic->RebuildConnectivity();
286 std::map<wxString, NET_ITEMS_BY_SHEET>
expected;
288 for(
const wxString&
name : names )
291 for(
const auto&
path : paths )
293 schematic->SetCurrentSheet(
path );
294 path.UpdateAllScreenReferences();
296 BOOST_CHECK( query.
NetNames() == names );
308 for(
const wxString& fixture : { wxString(
"net_chains_four_nets_labeled" ),
309 wxString(
"netlists/hierarchy_aliases/hierarchy_aliases" ) } )
313 std::unique_ptr<SCHEMATIC> schematic;
315 SCH_SCREEN* screen = schematic->Hierarchy().front().LastScreen();
321 if(
static_cast<SCH_LINE*
>( item )->IsWire() )
323 wire =
static_cast<SCH_LINE*
>( item->Clone() );
330 label =
static_cast<SCH_LABEL*
>( item->Clone() );
342 label->
SetText( wxString(
"CANDIDATE_BUS[0..1]" ) );
345 schematic->RebuildConnectivity();
346 const auto expected = schematic->GetNetClassAssignmentCandidates();
349 if( fixture == wxString(
"net_chains_four_nets_labeled" ) )
350 BOOST_CHECK(
expected.contains( wxString(
"/SIG" ) ) );
353 schematic->RebuildConnectivity();
354 schematic->ConnectionGraph()->Reset();
355 const auto actual = schematic->GetNetClassAssignmentCandidates();
360 for(
const auto&
group : schematic->Connectivity().GetNetMap() )
362 if( !
group.instances.empty() &&
group.instances.front().IsBus() )
369 if( fixture == wxString(
"netlists/hierarchy_aliases/hierarchy_aliases" ) )
370 BOOST_CHECK_GT( buses, 0u );
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
virtual void SetText(const wxString &aText)
EE_TYPE OfType(KICAD_T aType) const
One UI operation's hierarchy index.
std::vector< wxString > SignalNames(const wxString &aName) const
NET_ITEMS_BY_SHEET NetItems(const wxString &aName, bool aIncludeBusParents, bool aIncludeBusMembers=false) const
std::vector< wxString > NetNames() const
Base class for any item which can be embedded within the SCHEMATIC container class,...
std::optional< wxString > GetConnectionName(const SCH_SHEET_PATH *aSheet=nullptr, bool aLocal=false, bool aIgnoreSheet=false) const
Return the active connection name; absent for missing or stale published rows.
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Segment description base class to describe items which have 2 end points (track, wire,...
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
EE_RTREE & Items()
Get the full RTree, usually for iterating.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
RAII class that sets an value at construction and resets it to the original value at destruction.
bool m_ConnectivityEngine
Use the schematic connectivity engine instead of CONNECTION_GRAPH.
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
Value keys and the key session of the schematic connectivity engine.
std::map< SCH_SHEET_PATH, std::vector< SCH_ITEM * >, SHEET_PATH_CMP > NET_ITEMS_BY_SHEET
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE(AliasMemberQueriesMatchNativeMembership)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
VECTOR3I expected(15, 30, 45)
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I