KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_issue24330_netlist_pin_truncation.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
20// Regression test for https://gitlab.com/kicad/code/kicad/-/issues/24330
21
24
25#include <locale_io.h>
29#include <reporter.h>
30#include <schematic.h>
32
33#include <wx/ffile.h>
34#include <wx/filename.h>
35
36
38{
39 ISSUE24330_FIXTURE() = default;
40
42 std::unique_ptr<SCHEMATIC> m_schematic;
43};
44
45
46template <typename Exporter>
47static wxString writeAndReadNetlist( SCHEMATIC* aSch, const wxString& aSuffix, const wxString& aExt )
48{
49 wxFileName netFile = aSch->Project().GetProjectFullName();
50 netFile.SetName( netFile.GetName() + aSuffix );
51 netFile.SetExt( aExt );
52
54 std::unique_ptr<Exporter> exporter = std::make_unique<Exporter>( aSch, nullptr );
55
56 BOOST_REQUIRE( exporter->WriteNetlist( netFile.GetFullPath(), 0, reporter ) );
57 BOOST_REQUIRE( reporter.GetMessages().IsEmpty() );
58
59 wxString contents;
60 {
61 wxFFile fp( netFile.GetFullPath(), wxT( "rb" ) );
62 BOOST_REQUIRE( fp.IsOpened() );
63 fp.ReadAll( &contents );
64 }
65
66 wxRemoveFile( netFile.GetFullPath() );
67
68 return contents;
69}
70
71
72BOOST_FIXTURE_TEST_SUITE( Issue24330NetlistPinTruncation, ISSUE24330_FIXTURE )
73
74
75BOOST_AUTO_TEST_CASE( OrcadPCB2_PreservesLongPinNumbers )
76{
78 KI_TEST::LoadSchematic( m_settingsManager, wxT( "netlists/issue24330/issue24330" ),
79 m_schematic );
80
82 m_schematic.get(), wxT( "_test_orcad" ), wxT( "net" ) );
83
84 // OrcadPCB2 emits "( <pin_num> <net_name> )", so the trailing space distinguishes a
85 // genuine pin-number token from a coincidental substring inside a net name.
86 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "AAB10 " ) ),
87 "OrcadPCB2: pin number AAB10 missing or truncated" );
88 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "AAB11 " ) ),
89 "OrcadPCB2: pin number AAB11 missing or truncated" );
90 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "AAB12 " ) ),
91 "OrcadPCB2: pin number AAB12 missing or truncated" );
92}
93
94
95BOOST_AUTO_TEST_CASE( Cadstar_PreservesLongPinNumbers )
96{
98 KI_TEST::LoadSchematic( m_settingsManager, wxT( "netlists/issue24330/issue24330" ),
99 m_schematic );
100
102 m_schematic.get(), wxT( "_test_cadstar" ), wxT( "frp" ) );
103
104 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "AAB10" ) ),
105 "CadStar: pin number AAB10 missing or truncated" );
106 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "AAB11" ) ),
107 "CadStar: pin number AAB11 missing or truncated" );
108 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "AAB12" ) ),
109 "CadStar: pin number AAB12 missing or truncated" );
110}
111
112
113BOOST_AUTO_TEST_CASE( PADS_PreservesLongPinNumbers )
114{
116 KI_TEST::LoadSchematic( m_settingsManager, wxT( "netlists/issue24330/issue24330" ),
117 m_schematic );
118
120 m_schematic.get(), wxT( "_test_pads" ), wxT( "asc" ) );
121
122 // PADS uses "REF.PIN" connection format; check the full pin numbers are emitted.
123 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "U1.AAB10" ) ),
124 "PADS: pin connection U1.AAB10 missing or truncated" );
125 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "U1.AAB11" ) ),
126 "PADS: pin connection U1.AAB11 missing or truncated" );
127 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "U1.AAB12" ) ),
128 "PADS: pin connection U1.AAB12 missing or truncated" );
129}
130
131
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition locale_io.h:37
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition project.cpp:177
Holds all the data relating to one schematic.
Definition schematic.h:149
PROJECT & Project() const
Return a reference to the project this schematic is part of.
Definition schematic.h:171
A wrapper for reporting to a wxString object.
Definition reporter.h:242
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
std::vector< FAB_LAYER_COLOR > dummy
ISSUE24330_FIXTURE()=default
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()
BOOST_AUTO_TEST_CASE(OrcadPCB2_PreservesLongPinNumbers)
static wxString writeAndReadNetlist(SCHEMATIC *aSch, const wxString &aSuffix, const wxString &aExt)
std::string netlist
IbisParser parser & reporter