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 <alejandro.garciamontoro@gmail.com>
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 
31 #include <wx/init.h>
32 
34 
35 /*
36  * Simple function to handle a WX assertion and throw a real exception.
37  *
38  * This is useful when you want to check assertions fire in unit tests.
39  */
40 void wxAssertThrower( const wxString& aFile, int aLine, const wxString& aFunc,
41  const wxString& aCond, const wxString& aMsg )
42 {
43  throw KI_TEST::WX_ASSERT_ERROR( aFile, aLine, aFunc, aCond, aMsg );
44 }
45 
46 
48 {
49  boost::unit_test::framework::master_test_suite().p_name.value = "Common Eeschema module tests";
50 
51  bool ok = wxInitialize();
52 
53  wxSetAssertHandler( &wxAssertThrower );
54 
55  return ok;
56 }
57 
58 
59 int main( int argc, char* argv[] )
60 {
61  int ret = boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
62 
63  // This causes some glib warnings on GTK3 (http://trac.wxwidgets.org/ticket/18274)
64  // but without it, Valgrind notices a lot of leaks from WX
65  wxUninitialize();
66 
67  return ret;
68 }
An exception class to represent a WX assertion.
Definition: wx_assert.h:46
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.
int main(int argc, char *argv[])