KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_kibis.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) 2024 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
26#include <sim/kibis/kibis.h>
27
28namespace
29{
30std::string GetLibraryPath( const std::string& aBaseName )
31{
32 wxFileName fn( KI_TEST::GetEeschemaTestDataDir() );
33 fn.SetName( aBaseName );
34 fn.SetExt( "ibs" );
35 return std::string( fn.GetFullPath().ToUTF8() );
36}
37} // namespace
38
39
41
42
44{
45 KIBIS kibis;
46
47 BOOST_TEST( !kibis.m_valid );
48
49 // IBIS_ANY interface
50 // If this isn't null, it's uninited and access will crash
51 BOOST_REQUIRE( !kibis.m_reporter );
52
53 // Doesn't crash (also doesn't do anything)
54 kibis.Report( "Dummy", RPT_SEVERITY_INFO );
55}
56
57
59{
60 WX_STRING_REPORTER reporter;
61
62 std::string path = GetLibraryPath( "ibis_v1_1" );
63 KIBIS top( path, &reporter );
64
65 BOOST_TEST_INFO( "Parsed: " << path );
66 BOOST_TEST_INFO( "Reported: " << reporter.GetMessages() );
67
68 BOOST_TEST( top.m_valid );
69
70 KIBIS_MODEL* model = top.GetModel( "Input" );
71
72 BOOST_REQUIRE( model != nullptr );
73 BOOST_TEST_INFO( "Model: " << model->m_name );
74
75 BOOST_TEST( model->m_name == "Input" );
76 BOOST_TEST( (int) model->m_type == (int) IBIS_MODEL_TYPE::INPUT_STD );
79
80 BOOST_TEST( model->HasGNDClamp() );
81
82 KIBIS_COMPONENT* comp = top.GetComponent( "Virtual" );
83
84 BOOST_REQUIRE( comp != nullptr );
85
86 BOOST_TEST_INFO( "Component: " << comp->m_name );
87
88 BOOST_TEST( comp->m_name == "Virtual" );
89 BOOST_TEST( comp->m_pins.size() == 4 );
90}
91
KICAD_PLUGIN_EXPORT SCENEGRAPH * Load(char const *aFileName)
reads a model file and creates a generic display structure
REPORTER * m_reporter
Definition: ibis_parser.h:56
void Report(std::string aMsg, SEVERITY aSeverity=RPT_SEVERITY_INFO) const
Print a message.
Definition: ibis_parser.h:65
bool m_valid
Definition: kibis.h:57
std::vector< KIBIS_PIN > m_pins
Definition: kibis.h:441
std::string m_name
Name of the component.
Definition: kibis.h:437
IBIS_MODEL_ENABLE m_enable
Definition: kibis.h:246
std::string m_name
Definition: kibis.h:235
bool HasGNDClamp() const
Return true if the model has a clamp diode to the gnd net.
Definition: kibis.cpp:490
IBIS_MODEL_TYPE m_type
Definition: kibis.h:237
IBIS_MODEL_POLARITY m_polarity
Definition: kibis.h:247
Definition: kibis.h:452
KIBIS_MODEL * GetModel(const std::string &aName)
Return the model with name aName .
Definition: kibis.cpp:1393
KIBIS_COMPONENT * GetComponent(const std::string &aName)
Return the component with name aName .
Definition: kibis.cpp:1404
A wrapper for reporting to a wxString object.
Definition: reporter.h:171
const wxString & GetMessages() const
Definition: reporter.cpp:84
std::string GetEeschemaTestDataDir()
Get the configured location of Eeschema test data.
@ RPT_SEVERITY_INFO
BOOST_TEST(box.ClosestPointTo(VECTOR2D(0, 0))==VECTOR2D(1, 2))
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(Null)
Definition: test_kibis.cpp:43