KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_sch_netclass.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
21#include "eeschema_test_utils.h"
22
23#include <sch_sheet_path.h>
24#include <sch_label.h>
25
27{};
28
29BOOST_FIXTURE_TEST_SUITE( SchNetclass, TEST_SCH_NETCLASS_FIXTURE )
30
31
32BOOST_AUTO_TEST_CASE( TestSubsheetNetclass )
33{
34 LoadSchematic( "issue14494" );
35
36 SCH_SHEET_LIST sheets = m_schematic.GetSheets();
37 SCH_SHEET_PATH path = sheets.at( 1 );
38 SCH_SCREEN *screen = path.GetSheet( 1 )->GetScreen();
39
40 for( SCH_ITEM* item : screen->Items().OfType( SCH_HIER_LABEL_T ) )
41 {
42 SCH_HIERLABEL* label = static_cast<SCH_HIERLABEL*>( item );
43
44 wxString name = label->GetText();
45
46 if( name == wxT( "B" ) || name == wxT( "D" ) )
47 BOOST_CHECK_EQUAL( label->GetEffectiveNetClass( &path )->GetName(), "net_02" );
48 else
49 BOOST_CHECK_EQUAL( label->GetEffectiveNetClass( &path )->GetName(), "net_01" );
50 }
51}
52
53BOOST_AUTO_TEST_SUITE_END()
const char * name
Definition: DXF_plotter.cpp:57
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:98
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:238
A generic fixture for loading schematics and associated settings for qa tests.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:172
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
Definition: sch_item.cpp:239
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:109
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
static void LoadSchematic(SCHEMATIC *aSchematic, SCH_SHEET *aRootSheet, const wxString &aFileName)
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
BOOST_AUTO_TEST_CASE(TestSubsheetNetclass)
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:169