QA: Provide a common implementation of wxAssertThrower

Saves all the unit test modules having to copy-paste the
(simple) function.
This commit is contained in:
John Beard 2024-10-10 08:46:45 +08:00
parent 98da64dce7
commit 6ef078e9d8
4 changed files with 15 additions and 32 deletions

View File

@ -62,6 +62,18 @@ public:
std::string m_format_msg;
};
/*
* Simple function to handle a WX assertion and throw a real exception.
*
* This is useful when you want to check assertions fire in unit tests.
*/
inline void wxAssertThrower( const wxString& aFile, int aLine, const wxString& aFunc,
const wxString& aCond, const wxString& aMsg )
{
throw KI_TEST::WX_ASSERT_ERROR( aFile, aLine, aFunc, aCond, aMsg );
}
} // namespace KI_TEST
#endif // UNIT_TEST_UTILS_WX_ASSERT__H

View File

@ -22,13 +22,6 @@
#include <qa_utils/wx_utils/wx_assert.h>
void wxAssertThrower( const wxString& aFile, int aLine, const wxString& aFunc,
const wxString& aCond, const wxString& aMsg )
{
throw KI_TEST::WX_ASSERT_ERROR( aFile, aLine, aFunc, aCond, aMsg );
}
bool init_unit_test()
{
boost::unit_test::framework::master_test_suite().p_name.value = "IPC API tests";
@ -38,7 +31,7 @@ bool init_unit_test()
bool ok = wxInitialize( boost::unit_test::framework::master_test_suite().argc,
boost::unit_test::framework::master_test_suite().argv );
wxSetAssertHandler( &wxAssertThrower );
wxSetAssertHandler( &KI_TEST::wxAssertThrower );
return ok;
}

View File

@ -39,17 +39,6 @@
#include <qa_utils/wx_utils/wx_assert.h>
/*
* Simple function to handle a WX assertion and throw a real exception.
*
* This is useful when you want to check assertions fire in unit tests.
*/
void wxAssertThrower( const wxString& aFile, int aLine, const wxString& aFunc,
const wxString& aCond, const wxString& aMsg )
{
throw KI_TEST::WX_ASSERT_ERROR( aFile, aLine, aFunc, aCond, aMsg );
}
bool init_unit_test()
{
@ -62,7 +51,7 @@ bool init_unit_test()
bool ok = wxInitialize( boost::unit_test::framework::master_test_suite().argc,
boost::unit_test::framework::master_test_suite().argv );
wxSetAssertHandler( &wxAssertThrower );
wxSetAssertHandler( &KI_TEST::wxAssertThrower );
Pgm().InitPgm( true, true, true );
Pgm().GetSettingsManager().RegisterSettings( new EESCHEMA_SETTINGS, false );

View File

@ -39,17 +39,6 @@
#include <qa_utils/wx_utils/wx_assert.h>
/*
* Simple function to handle a WX assertion and throw a real exception.
*
* This is useful when you want to check assertions fire in unit tests.
*/
void wxAssertThrower( const wxString& aFile, int aLine, const wxString& aFunc,
const wxString& aCond, const wxString& aMsg )
{
throw KI_TEST::WX_ASSERT_ERROR( aFile, aLine, aFunc, aCond, aMsg );
}
bool init_unit_test()
{
@ -62,7 +51,7 @@ bool init_unit_test()
bool ok = wxInitialize( boost::unit_test::framework::master_test_suite().argc,
boost::unit_test::framework::master_test_suite().argv );
wxSetAssertHandler( &wxAssertThrower );
wxSetAssertHandler( &KI_TEST::wxAssertThrower );
Pgm().InitPgm( true, true, true );
Pgm().GetSettingsManager().RegisterSettings( new EESCHEMA_SETTINGS, false );