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#include <sch_io/sch_io.h>
28
30{};
31
32BOOST_FIXTURE_TEST_SUITE( SchNetclass, TEST_SCH_NETCLASS_FIXTURE )
33
34
35BOOST_AUTO_TEST_CASE( TestSubsheetNetclass )
36{
37 LoadSchematic( "issue14494" );
38
39 SCH_SHEET_PATH path = m_schematic.BuildSheetListSortedByPageNumbers().at( 1 );
40 SCH_SCREEN* screen = path.GetSheet( 1 )->GetScreen();
41
42 for( SCH_ITEM* item : screen->Items().OfType( SCH_HIER_LABEL_T ) )
43 {
44 SCH_HIERLABEL* label = static_cast<SCH_HIERLABEL*>( item );
45
46 wxString name = label->GetText();
47
48 if( name == wxT( "B" ) || name == wxT( "D" ) )
49 BOOST_CHECK_EQUAL( label->GetEffectiveNetClass( &path )->GetName(), "net_02" );
50 else
51 BOOST_CHECK_EQUAL( label->GetEffectiveNetClass( &path )->GetName(), "net_01" );
52 }
53}
54
55BOOST_AUTO_TEST_CASE( TestMultiNetclasses )
56{
57 LoadSchematic( "multinetclasses" );
58
59 std::shared_ptr<NET_SETTINGS>& netSettings = m_schematic.Prj().GetProjectFile().m_NetSettings;
60
61 std::shared_ptr<NETCLASS> nc = netSettings->GetEffectiveNetClass( "/BUS.SIGNAL" );
62 BOOST_CHECK_EQUAL( nc->GetVariableSubstitutionName(), "CLASS2,CLASS1,Default" );
63
64 nc = netSettings->GetEffectiveNetClass( "/BUS.A0" );
65 BOOST_CHECK_EQUAL( nc->GetVariableSubstitutionName(), "CLASS1,CLASS3,Default" );
66
67 nc = netSettings->GetEffectiveNetClass( "/BUS.A1" );
68 BOOST_CHECK_EQUAL( nc->GetVariableSubstitutionName(), "CLASS1,Default" );
69
70 nc = netSettings->GetEffectiveNetClass( "/BUS.A2" );
71 wxString name = nc->GetName();
72 BOOST_CHECK_EQUAL( nc->GetVariableSubstitutionName(), "CLASS1,CLASS4,Default" );
73
74 nc = netSettings->GetEffectiveNetClass( "/NET_1" );
75 BOOST_CHECK_EQUAL( nc->GetVariableSubstitutionName(), "CLASS2,CLASS3,Default" );
76
77 nc = netSettings->GetEffectiveNetClass( "/NET_2" );
78 BOOST_CHECK_EQUAL( nc->GetVariableSubstitutionName(), "CLASS_COMPLETE" );
79
80 nc = netSettings->GetEffectiveNetClass( "/NET_3" );
81 BOOST_CHECK_EQUAL( nc->GetVariableSubstitutionName(), "CLASS_COMPLETE,CLASS3,CLASS4" );
82
83 nc = netSettings->GetEffectiveNetClass( "/NET_4" );
84 BOOST_CHECK_EQUAL( nc->GetVariableSubstitutionName(), "CLASS_COMPLETE,CLASS3,CLASS4" );
85}
86
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:166
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
Definition: sch_item.cpp:247
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:108
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_SUITE_END()
BOOST_AUTO_TEST_CASE(TestSubsheetNetclass)
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:169