KiCad PCB EDA Suite
eeschema/test_module.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) 2017 CERN
5 * @author Alejandro García Montoro <[email protected]>
6 * Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
29#include <boost/test/unit_test.hpp>
30#include <kiplatform/app.h>
31
32#include <pgm_base.h>
33#include <wx/app.h>
34#include <wx/init.h>
35
37
38/*
39 * Simple function to handle a WX assertion and throw a real exception.
40 *
41 * This is useful when you want to check assertions fire in unit tests.
42 */
43void wxAssertThrower( const wxString& aFile, int aLine, const wxString& aFunc,
44 const wxString& aCond, const wxString& aMsg )
45{
46 throw KI_TEST::WX_ASSERT_ERROR( aFile, aLine, aFunc, aCond, aMsg );
47}
48
49
51{
53 boost::unit_test::framework::master_test_suite().p_name.value = "Common Eeschema module tests";
54
55 wxApp::SetInstance( new wxAppConsole );
56
57 bool ok = wxInitialize( boost::unit_test::framework::master_test_suite().argc,
58 boost::unit_test::framework::master_test_suite().argv );
59
60 wxSetAssertHandler( &wxAssertThrower );
61
62 Pgm().InitPgm( true, true );
63
64 return ok;
65}
66
67
68int main( int argc, char* argv[] )
69{
70 int ret = boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
71
72 Pgm().Destroy();
73
74 // This causes some glib warnings on GTK3 (http://trac.wxwidgets.org/ticket/18274)
75 // but without it, Valgrind notices a lot of leaks from WX
76 wxUninitialize();
77
78 return ret;
79}
An exception class to represent a WX assertion.
Definition: wx_assert.h:47
int main(int argc, char *argv[])
bool init_unit_test()
void wxAssertThrower(const wxString &aFile, int aLine, const wxString &aFunc, const wxString &aCond, const wxString &aMsg)
Main file for the Eeschema tests to be compiled.
bool Init()
Perform application-specific initialization tasks.
Definition: gtk/app.cpp:40
see class PGM_BASE
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111