Integrate QmuParserTests in main testing set.
--HG-- branch : develop
This commit is contained in:
parent
ba89a2856d
commit
a4bc4a75c0
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QCoreApplication>
|
||||||
#include "qmuparsererror.h"
|
#include "qmuparsererror.h"
|
||||||
#include <QtCore/qmath.h>
|
#include <QtCore/qmath.h>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
@ -41,8 +42,8 @@ namespace Test
|
||||||
int QmuParserTester::c_iCount = 0;
|
int QmuParserTester::c_iCount = 0;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QmuParserTester::QmuParserTester()
|
QmuParserTester::QmuParserTester(QObject *parent)
|
||||||
: m_vTestFun()
|
: QObject(parent), m_vTestFun()
|
||||||
{
|
{
|
||||||
AddTest ( &QmuParserTester::TestNames );
|
AddTest ( &QmuParserTester::TestNames );
|
||||||
AddTest ( &QmuParserTester::TestSyntax );
|
AddTest ( &QmuParserTester::TestSyntax );
|
||||||
|
@ -1098,6 +1099,9 @@ void QmuParserTester::AddTest ( testfun_type a_pFun )
|
||||||
// cppcheck-suppress unusedFunction
|
// cppcheck-suppress unusedFunction
|
||||||
void QmuParserTester::Run()
|
void QmuParserTester::Run()
|
||||||
{
|
{
|
||||||
|
qWarning() << "-----------------------------------------------------------";
|
||||||
|
qWarning() << "Running test suite:\n";
|
||||||
|
|
||||||
int iStat = 0;
|
int iStat = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1111,16 +1115,19 @@ void QmuParserTester::Run()
|
||||||
qWarning() << "\n" << e.GetMsg();
|
qWarning() << "\n" << e.GetMsg();
|
||||||
qWarning() << e.GetToken();
|
qWarning() << e.GetToken();
|
||||||
Abort();
|
Abort();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
catch ( std::exception &e )
|
catch ( std::exception &e )
|
||||||
{
|
{
|
||||||
qWarning() << e.what();
|
qWarning() << e.what();
|
||||||
Abort();
|
Abort();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
catch ( ... )
|
catch ( ... )
|
||||||
{
|
{
|
||||||
qWarning() << "Internal error";
|
qWarning() << "Internal error";
|
||||||
Abort();
|
Abort();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( iStat == 0 )
|
if ( iStat == 0 )
|
||||||
|
@ -1133,7 +1140,11 @@ void QmuParserTester::Run()
|
||||||
<< " errors (" << QmuParserTester::c_iCount
|
<< " errors (" << QmuParserTester::c_iCount
|
||||||
<< " expressions)";
|
<< " expressions)";
|
||||||
}
|
}
|
||||||
|
QCoreApplication::exit(iStat);
|
||||||
QmuParserTester::c_iCount = 0;
|
QmuParserTester::c_iCount = 0;
|
||||||
|
|
||||||
|
qWarning() << "Done.";
|
||||||
|
qWarning() << "-----------------------------------------------------------";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1498,11 +1509,11 @@ int QmuParserTester::EqnTestBulk(const QString &a_str, double a_fRes[4], bool a_
|
||||||
/**
|
/**
|
||||||
* @brief Internal error in test class Test is going to be aborted.
|
* @brief Internal error in test class Test is going to be aborted.
|
||||||
*/
|
*/
|
||||||
void Q_NORETURN QmuParserTester::Abort()
|
void QmuParserTester::Abort()
|
||||||
{
|
{
|
||||||
qWarning() << "Test failed (internal error in test class)";
|
qWarning() << "Test failed (internal error in test class)";
|
||||||
while ( getchar() == false);
|
while ( getchar() == false);
|
||||||
exit ( -1 );
|
QCoreApplication::exit ( -1 );
|
||||||
}
|
}
|
||||||
} // namespace test
|
} // namespace test
|
||||||
} // namespace qmu
|
} // namespace qmu
|
||||||
|
|
|
@ -44,14 +44,19 @@ namespace Test
|
||||||
*
|
*
|
||||||
* (C) 2004-2011 Ingo Berg
|
* (C) 2004-2011 Ingo Berg
|
||||||
*/
|
*/
|
||||||
class QMUPARSERSHARED_EXPORT QmuParserTester // final
|
class QMUPARSERSHARED_EXPORT QmuParserTester : public QObject // final
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
typedef int ( QmuParserTester::*testfun_type ) ();
|
typedef int ( QmuParserTester::*testfun_type ) ();
|
||||||
|
|
||||||
QmuParserTester();
|
QmuParserTester(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
public slots:
|
||||||
void Run();
|
void Run();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Q_DISABLE_COPY(QmuParserTester)
|
||||||
QVector<testfun_type> m_vTestFun;
|
QVector<testfun_type> m_vTestFun;
|
||||||
static int c_iCount;
|
static int c_iCount;
|
||||||
|
|
||||||
|
@ -307,7 +312,7 @@ private:
|
||||||
// cppcheck-suppress functionStatic
|
// cppcheck-suppress functionStatic
|
||||||
int TestBulkMode();
|
int TestBulkMode();
|
||||||
|
|
||||||
static void Q_NORETURN Abort();
|
static void Abort();
|
||||||
};
|
};
|
||||||
} // namespace Test
|
} // namespace Test
|
||||||
} // namespace qmu
|
} // namespace qmu
|
||||||
|
|
|
@ -21,6 +21,11 @@ TARGET = ParserTest
|
||||||
# Console application, we use C++11 standard.
|
# Console application, we use C++11 standard.
|
||||||
CONFIG += console c++11
|
CONFIG += console c++11
|
||||||
|
|
||||||
|
# CONFIG += testcase adds a 'make check' which is great. But by default it also
|
||||||
|
# adds a 'make install' that installs the test cases, which we do not want.
|
||||||
|
# Can configure it not to do that with 'no_testcase_installs'
|
||||||
|
CONFIG += testcase no_testcase_installs
|
||||||
|
|
||||||
# Use out-of-source builds (shadow builds)
|
# Use out-of-source builds (shadow builds)
|
||||||
CONFIG -= app_bundle debug_and_release debug_and_release_target
|
CONFIG -= app_bundle debug_and_release debug_and_release_target
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,12 @@
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QTimer>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include "../qmuparser/qmuparsertest.h"
|
#include "../qmuparser/qmuparsertest.h"
|
||||||
|
|
||||||
using namespace qmu;
|
using namespace qmu;
|
||||||
|
using namespace Test;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void testMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
void testMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||||
|
@ -62,18 +64,8 @@ void testMessageOutput(QtMsgType type, const QMessageLogContext &context, const
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QCoreApplication a(argc, argv);
|
QCoreApplication a(argc, argv);
|
||||||
|
|
||||||
qInstallMessageHandler(testMessageOutput);
|
qInstallMessageHandler(testMessageOutput);
|
||||||
|
QmuParserTester pt;
|
||||||
qWarning() << "-----------------------------------------------------------";
|
QTimer::singleShot(0, &pt, SLOT(Run()));
|
||||||
qWarning() << "Running test suite:\n";
|
|
||||||
|
|
||||||
|
|
||||||
qmu::Test::QmuParserTester pt;
|
|
||||||
pt.Run();
|
|
||||||
|
|
||||||
qWarning() << "Done.";
|
|
||||||
qWarning() << "-----------------------------------------------------------";
|
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user