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,
48 const wxString& aExt )
49{
50 wxFileName netFile = aSch->Project().GetProjectFullName();
51 netFile.SetName( netFile.GetName() + aSuffix );
52 netFile.SetExt( aExt );
53
55 std::unique_ptr<Exporter> exporter = std::make_unique<Exporter>( aSch );
56
57 BOOST_REQUIRE( exporter->WriteNetlist( netFile.GetFullPath(), 0, reporter ) );
58 BOOST_REQUIRE( reporter.GetMessages().IsEmpty() );
59
60 wxString contents;
61 {
62 wxFFile fp( netFile.GetFullPath(), wxT( "rb" ) );
63 BOOST_REQUIRE( fp.IsOpened() );
64 fp.ReadAll( &contents );
65 }
66
67 wxRemoveFile( netFile.GetFullPath() );
68
69 return contents;
70}
71
72
73BOOST_FIXTURE_TEST_SUITE( Issue24330NetlistPinTruncation, ISSUE24330_FIXTURE )
74
75
76BOOST_AUTO_TEST_CASE( OrcadPCB2_PreservesLongPinNumbers )
77{
79 KI_TEST::LoadSchematic( m_settingsManager, wxT( "netlists/issue24330/issue24330" ),
80 m_schematic );
81
83 m_schematic.get(), wxT( "_test_orcad" ), wxT( "net" ) );
84
85 // OrcadPCB2 emits "( <pin_num> <net_name> )", so the trailing space distinguishes a
86 // genuine pin-number token from a coincidental substring inside a net name.
87 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "AAB10 " ) ),
88 "OrcadPCB2: pin number AAB10 missing or truncated" );
89 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "AAB11 " ) ),
90 "OrcadPCB2: pin number AAB11 missing or truncated" );
91 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "AAB12 " ) ),
92 "OrcadPCB2: pin number AAB12 missing or truncated" );
93}
94
95
96BOOST_AUTO_TEST_CASE( Cadstar_PreservesLongPinNumbers )
97{
99 KI_TEST::LoadSchematic( m_settingsManager, wxT( "netlists/issue24330/issue24330" ),
100 m_schematic );
101
103 m_schematic.get(), wxT( "_test_cadstar" ), wxT( "frp" ) );
104
105 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "AAB10" ) ),
106 "CadStar: pin number AAB10 missing or truncated" );
107 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "AAB11" ) ),
108 "CadStar: pin number AAB11 missing or truncated" );
109 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "AAB12" ) ),
110 "CadStar: pin number AAB12 missing or truncated" );
111}
112
113
114BOOST_AUTO_TEST_CASE( PADS_PreservesLongPinNumbers )
115{
117 KI_TEST::LoadSchematic( m_settingsManager, wxT( "netlists/issue24330/issue24330" ),
118 m_schematic );
119
121 m_schematic.get(), wxT( "_test_pads" ), wxT( "asc" ) );
122
123 // PADS uses "REF.PIN" connection format; check the full pin numbers are emitted.
124 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "U1.AAB10" ) ),
125 "PADS: pin connection U1.AAB10 missing or truncated" );
126 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "U1.AAB11" ) ),
127 "PADS: pin connection U1.AAB11 missing or truncated" );
128 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "U1.AAB12" ) ),
129 "PADS: pin connection U1.AAB12 missing or truncated" );
130}
131
132
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:90
PROJECT & Project() const
Return a reference to the project this schematic is part of.
Definition schematic.h:105
A wrapper for reporting to a wxString object.
Definition reporter.h:189
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
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")