7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2024-11-22 04:05:02 +00:00
kicad/qa/tests/eeschema/test_sch_netclass.cpp
John Beard 3d6d8b9946 Strip richio.h from headers that don't need them
Like the DSNLEXER header, this has visibility in over 700
files, whereas well under half actually use any of it
(quite a bit, but not all, of it actually via DSNLEXER)

Many places already forward-declare the OUTPUTFORMATTER type,
by doing that for the others, it still possible to use the
non-IO methods without having to see richio.h.
2024-10-04 18:06:18 +01:00

88 lines
3.2 KiB
C++

/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <qa_utils/wx_utils/unit_test_utils.h>
#include "eeschema_test_utils.h"
#include <sch_sheet_path.h>
#include <sch_label.h>
#include <sch_io/sch_io.h>
#include <project/net_settings.h>
#include <project/project_file.h>
class TEST_SCH_NETCLASS_FIXTURE : public KI_TEST::SCHEMATIC_TEST_FIXTURE
{};
BOOST_FIXTURE_TEST_SUITE( SchNetclass, TEST_SCH_NETCLASS_FIXTURE )
BOOST_AUTO_TEST_CASE( TestSubsheetNetclass )
{
LoadSchematic( "issue14494" );
SCH_SHEET_PATH path = m_schematic.BuildSheetListSortedByPageNumbers().at( 1 );
SCH_SCREEN* screen = path.GetSheet( 1 )->GetScreen();
for( SCH_ITEM* item : screen->Items().OfType( SCH_HIER_LABEL_T ) )
{
SCH_HIERLABEL* label = static_cast<SCH_HIERLABEL*>( item );
wxString name = label->GetText();
if( name == wxT( "B" ) || name == wxT( "D" ) )
BOOST_CHECK_EQUAL( label->GetEffectiveNetClass( &path )->GetName(), "net_02" );
else
BOOST_CHECK_EQUAL( label->GetEffectiveNetClass( &path )->GetName(), "net_01" );
}
}
BOOST_AUTO_TEST_CASE( TestMultiNetclasses )
{
LoadSchematic( "multinetclasses" );
std::shared_ptr<NET_SETTINGS>& netSettings = m_schematic.Prj().GetProjectFile().m_NetSettings;
std::shared_ptr<NETCLASS> nc = netSettings->GetEffectiveNetClass( "/BUS.SIGNAL" );
BOOST_CHECK_EQUAL( nc->GetVariableSubstitutionName(), "CLASS2,CLASS1,Default" );
nc = netSettings->GetEffectiveNetClass( "/BUS.A0" );
BOOST_CHECK_EQUAL( nc->GetVariableSubstitutionName(), "CLASS1,CLASS3,Default" );
nc = netSettings->GetEffectiveNetClass( "/BUS.A1" );
BOOST_CHECK_EQUAL( nc->GetVariableSubstitutionName(), "CLASS1,Default" );
nc = netSettings->GetEffectiveNetClass( "/BUS.A2" );
wxString name = nc->GetName();
BOOST_CHECK_EQUAL( nc->GetVariableSubstitutionName(), "CLASS1,CLASS4,Default" );
nc = netSettings->GetEffectiveNetClass( "/NET_1" );
BOOST_CHECK_EQUAL( nc->GetVariableSubstitutionName(), "CLASS2,CLASS3,Default" );
nc = netSettings->GetEffectiveNetClass( "/NET_2" );
BOOST_CHECK_EQUAL( nc->GetVariableSubstitutionName(), "CLASS_COMPLETE" );
nc = netSettings->GetEffectiveNetClass( "/NET_3" );
BOOST_CHECK_EQUAL( nc->GetVariableSubstitutionName(), "CLASS_COMPLETE,CLASS3,CLASS4" );
nc = netSettings->GetEffectiveNetClass( "/NET_4" );
BOOST_CHECK_EQUAL( nc->GetVariableSubstitutionName(), "CLASS_COMPLETE,CLASS3,CLASS4" );
}
BOOST_AUTO_TEST_SUITE_END()