KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_sim_regressions.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 (C) 2023 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 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
25#include <boost/test/results_collector.hpp> // To check if the current test failed (to be moved?).
26#include <eeschema_test_utils.h>
28#include <wx/ffile.h>
29#include <mock_pgm_base.h>
30#include <locale_io.h>
31
32
34{
35public:
38 {
39 }
40
42 {
43 }
44
45 wxFileName GetSchematicPath( const wxString& aBaseName ) override
46 {
47 wxFileName fn( KI_TEST::GetEeschemaTestDataDir() );
48 fn.SetName( aBaseName );
49 fn.SetExt( KiCadSchematicFileExtension );
50
51 return fn;
52 }
53
54 wxString GetNetlistPath( bool aTest = false ) override
55 {
56 wxFileName netFile = m_schematic.Prj().GetProjectFullName();
57
58 if( aTest )
59 netFile.SetName( netFile.GetName() + "_test" );
60
61 netFile.SetExt( "spice" );
62 return netFile.GetFullPath();
63 }
64
65 unsigned GetNetlistOptions() override
66 {
69
70 if( m_SaveCurrents )
72
73 if( m_SaveVoltages )
75
78
79 return options;
80 }
81
82public:
83 bool m_SavesDissipations = false;
84 bool m_SaveVoltages = true;
85 bool m_SaveCurrents = true;
86};
87
88
90{
92
93 const MOCK_PGM_BASE& program = static_cast<MOCK_PGM_BASE&>( Pgm() );
94 MOCK_EXPECT( program.GetLocalEnvVariables ).returns( ENV_VAR_MAP() );
95
96 TestNetlist( "issue13591" );
97 TestTranPoint( 100e-6, { { "I(R1)", 0 }, { "I(R2)", 0 } }, 0.00001 );
98 TestTranPoint( 500e-6, { { "I(R1)", 0 }, { "I(R2)", 0 } }, 0.00001 );
99}
100
101
103{
105
106 m_SaveCurrents = false;
107
108 TestNetlist( "issue13431" );
109 TestTranPoint( 0.005, { { "V(/soft_start)", 2.489 } } );
110 TestTranPoint( 0.012, { { "V(/soft_start)", 5.100 } } );
111}
112
113
115{
117
118 const MOCK_PGM_BASE& program = static_cast<MOCK_PGM_BASE&>( Pgm() );
119 MOCK_EXPECT( program.GetLocalEnvVariables ).returns( ENV_VAR_MAP() );
120
121 TestNetlist( "issue13112" );
122 TestTranPoint( 0.01, { { "V(out)", -0.060 } } );
123 TestTranPoint( 0.02, { { "V(out)", 0.856 } } );
124}
125
126
128{
130
131 const MOCK_PGM_BASE& program = static_cast<MOCK_PGM_BASE&>( Pgm() );
132 MOCK_EXPECT( program.GetLocalEnvVariables ).returns( ENV_VAR_MAP() );
133
134 TestNetlist( "issue13162" );
135 TestTranPoint( 0.030, { { "V(out)", 0.557 } } );
136 TestTranPoint( 0.035, { { "V(out)", -1.437 } } );
137}
138
139
141{
143
144 const MOCK_PGM_BASE& program = static_cast<MOCK_PGM_BASE&>( Pgm() );
145 MOCK_EXPECT( program.GetLocalEnvVariables ).returns( ENV_VAR_MAP() );
146
147 TestNetlist( "issue12505" );
148 TestTranPoint( 0.015, { { "V(Net-_R1-Pad2_)", -311 } } );
149 TestTranPoint( 0.025, { { "V(Net-_R1-Pad2_)", 311 } } );
150}
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:49
virtual ENV_VAR_MAP & GetLocalEnvVariables() const
Definition: pgm_base.cpp:871
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:137
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:90
wxFileName GetSchematicPath(const wxString &aBaseName) override
wxString GetNetlistPath(bool aTest=false) override
const std::string KiCadSchematicFileExtension
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
std::string GetEeschemaTestDataDir()
Get the configured location of Eeschema test data.
PGM_SINGLE_TOP program
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:115
std::vector< FAB_LAYER_COLOR > dummy
BOOST_FIXTURE_TEST_CASE(WindowsPaths, TEST_SIM_REGRESSIONS_FIXTURE)