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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 */
20
21// Regression test for https://gitlab.com/kicad/code/kicad/-/issues/24330
22
25
26#include <locale_io.h>
30#include <reporter.h>
31#include <schematic.h>
33
34#include <wx/ffile.h>
35#include <wx/filename.h>
36
37
39{
40 ISSUE24330_FIXTURE() = default;
41
43 std::unique_ptr<SCHEMATIC> m_schematic;
44};
45
46
47template <typename Exporter>
48static wxString writeAndReadNetlist( SCHEMATIC* aSch, const wxString& aSuffix,
49 const wxString& aExt )
50{
51 wxFileName netFile = aSch->Project().GetProjectFullName();
52 netFile.SetName( netFile.GetName() + aSuffix );
53 netFile.SetExt( aExt );
54
56 std::unique_ptr<Exporter> exporter = std::make_unique<Exporter>( aSch );
57
58 BOOST_REQUIRE( exporter->WriteNetlist( netFile.GetFullPath(), 0, reporter ) );
59 BOOST_REQUIRE( reporter.GetMessages().IsEmpty() );
60
61 wxString contents;
62 {
63 wxFFile fp( netFile.GetFullPath(), wxT( "rb" ) );
64 BOOST_REQUIRE( fp.IsOpened() );
65 fp.ReadAll( &contents );
66 }
67
68 wxRemoveFile( netFile.GetFullPath() );
69
70 return contents;
71}
72
73
74BOOST_FIXTURE_TEST_SUITE( Issue24330NetlistPinTruncation, ISSUE24330_FIXTURE )
75
76
77BOOST_AUTO_TEST_CASE( OrcadPCB2_PreservesLongPinNumbers )
78{
80 KI_TEST::LoadSchematic( m_settingsManager, wxT( "netlists/issue24330/issue24330" ),
81 m_schematic );
82
84 m_schematic.get(), wxT( "_test_orcad" ), wxT( "net" ) );
85
86 // OrcadPCB2 emits "( <pin_num> <net_name> )", so the trailing space distinguishes a
87 // genuine pin-number token from a coincidental substring inside a net name.
88 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "AAB10 " ) ),
89 "OrcadPCB2: pin number AAB10 missing or truncated" );
90 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "AAB11 " ) ),
91 "OrcadPCB2: pin number AAB11 missing or truncated" );
92 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "AAB12 " ) ),
93 "OrcadPCB2: pin number AAB12 missing or truncated" );
94}
95
96
97BOOST_AUTO_TEST_CASE( Cadstar_PreservesLongPinNumbers )
98{
100 KI_TEST::LoadSchematic( m_settingsManager, wxT( "netlists/issue24330/issue24330" ),
101 m_schematic );
102
104 m_schematic.get(), wxT( "_test_cadstar" ), wxT( "frp" ) );
105
106 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "AAB10" ) ),
107 "CadStar: pin number AAB10 missing or truncated" );
108 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "AAB11" ) ),
109 "CadStar: pin number AAB11 missing or truncated" );
110 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "AAB12" ) ),
111 "CadStar: pin number AAB12 missing or truncated" );
112}
113
114
115BOOST_AUTO_TEST_CASE( PADS_PreservesLongPinNumbers )
116{
118 KI_TEST::LoadSchematic( m_settingsManager, wxT( "netlists/issue24330/issue24330" ),
119 m_schematic );
120
122 m_schematic.get(), wxT( "_test_pads" ), wxT( "asc" ) );
123
124 // PADS uses "REF.PIN" connection format; check the full pin numbers are emitted.
125 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "U1.AAB10" ) ),
126 "PADS: pin connection U1.AAB10 missing or truncated" );
127 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "U1.AAB11" ) ),
128 "PADS: pin connection U1.AAB11 missing or truncated" );
129 BOOST_CHECK_MESSAGE( netlist.Contains( wxT( "U1.AAB12" ) ),
130 "PADS: pin connection U1.AAB12 missing or truncated" );
131}
132
133
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition locale_io.h:41
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition project.cpp:181
Holds all the data relating to one schematic.
Definition schematic.h:89
PROJECT & Project() const
Return a reference to the project this schematic is part of.
Definition schematic.h:104
A wrapper for reporting to a wxString object.
Definition reporter.h:193
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")