KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_issue25469_empty_sheet_pin_name.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 The KiCad Developers, see AUTHORS.TXT for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26
27#include <boost/test/unit_test.hpp>
28#include <eeschema_test_utils.h>
29
31#include <sch_screen.h>
32#include <sch_sheet.h>
33#include <sch_sheet_pin.h>
34#include <schematic.h>
37#include <locale_io.h>
39
40#include <wx/filename.h>
41
42
44{
46 {
47 wxFileName projectPath( KI_TEST::GetEeschemaTestDataDir() );
48 projectPath.AppendDir( "issue25469" );
49 projectPath.SetName( "issue25469" );
50 projectPath.SetExt( FILEEXT::ProjectFileExtension );
51
52 m_settingsManager.LoadProject( projectPath.GetFullPath().ToStdString() );
53 m_schematic = std::make_unique<SCHEMATIC>( nullptr );
54 m_schematic->SetProject( &m_settingsManager.Prj() );
55 }
56
58 {
59 m_schematic.reset();
60 }
61
63 std::unique_ptr<SCHEMATIC> m_schematic;
64};
65
66
67BOOST_FIXTURE_TEST_SUITE( Issue25469EmptySheetPinName, ISSUE25469_FIXTURE )
68
69
70BOOST_AUTO_TEST_CASE( LoadsSheetWithUnnamedPin )
71{
73
74 wxFileName dataDir( KI_TEST::GetEeschemaTestDataDir() );
75 dataDir.AppendDir( "issue25469" );
76
77 wxFileName rootFile( dataDir.GetPath(), "issue25469", FILEEXT::KiCadSchematicFileExtension );
78
79 BOOST_REQUIRE_MESSAGE( rootFile.FileExists(),
80 "Test data missing: " + rootFile.GetFullPath().ToStdString() );
81
83 SCH_SHEET* root = nullptr;
84
85 BOOST_REQUIRE_NO_THROW( root = io.LoadSchematicFile( rootFile.GetFullPath(),
86 m_schematic.get() ) );
87 BOOST_REQUIRE( root != nullptr );
88 BOOST_REQUIRE( root->GetScreen() != nullptr );
89
90 int pinCount = 0;
91 int unnamedPinCount = 0;
92
93 for( SCH_ITEM* item : root->GetScreen()->Items().OfType( SCH_SHEET_T ) )
94 {
95 for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
96 {
97 pinCount++;
98
99 if( pin->GetText().IsEmpty() )
100 unnamedPinCount++;
101 }
102 }
103
104 BOOST_CHECK_EQUAL( pinCount, 3 );
105 BOOST_CHECK_EQUAL( unnamedPinCount, 1 );
106
107 delete root;
108}
109
110
EE_TYPE OfType(KICAD_T aType) const
Definition sch_rtree.h:248
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition locale_io.h:37
A SCH_IO derivation for loading schematic files using the new s-expression file format.
SCH_SHEET * LoadSchematicFile(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load information from some input file format that this SCH_IO implementation knows about,...
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:165
EE_RTREE & Items()
Get the full RTree, usually for iterating.
Definition sch_screen.h:118
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:48
SCH_SCREEN * GetScreen() const
Definition sch_sheet.h:145
static const std::string ProjectFileExtension
static const std::string KiCadSchematicFileExtension
std::string GetEeschemaTestDataDir()
Get the configured location of Eeschema test data.
std::vector< FAB_LAYER_COLOR > dummy
std::unique_ptr< SCHEMATIC > m_schematic
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
KIBIS_PIN * pin
BOOST_CHECK_EQUAL(result, "25.4")
@ SCH_SHEET_T
Definition typeinfo.h:171
Definition of file extensions used in Kicad.