22 #ifndef QMUPARSERTEST_H
23 #define QMUPARSERTEST_H
26 #include <QMetaObject>
31 #include <QRandomGenerator>
33 #include <QRandomGenerator>
76 static
int EqnTest ( const QString &a_str,
double a_fRes,
bool a_fPass );
77 static
int EqnTestWithVarChange (const QString &a_str,
double a_fRes1,
double a_fVar1,
double a_fRes2,
79 static
int ThrowTest ( const QString &a_str,
int a_iErrc,
bool a_bFail = true );
82 static
int EqnTestBulk(const QString &a_str,
double a_fRes[4],
bool a_fPass);
90 static qreal
f1of2 ( qreal v, qreal )
95 static qreal
f2of2 ( qreal, qreal v )
100 static qreal
f1of3 ( qreal v, qreal, qreal )
105 static qreal
f2of3 ( qreal, qreal v, qreal )
110 static qreal
f3of3 ( qreal, qreal, qreal v )
115 static qreal
f1of4 ( qreal v, qreal, qreal, qreal )
120 static qreal
f2of4 ( qreal, qreal v, qreal, qreal )
125 static qreal
f3of4 ( qreal, qreal, qreal v, qreal )
130 static qreal
f4of4 ( qreal, qreal, qreal, qreal v )
135 static qreal
f1of5 ( qreal v, qreal, qreal, qreal, qreal )
140 static qreal
f2of5 ( qreal, qreal v, qreal, qreal, qreal )
145 static qreal
f3of5 ( qreal, qreal, qreal v, qreal, qreal )
150 static qreal
f4of5 ( qreal, qreal, qreal, qreal v, qreal )
155 static qreal
f5of5 ( qreal, qreal, qreal, qreal, qreal v )
160 static qreal
Min ( qreal a_fVal1, qreal a_fVal2 )
162 return ( a_fVal1 < a_fVal2 ) ? a_fVal1 : a_fVal2;
165 static qreal
Max ( qreal a_fVal1, qreal a_fVal2 )
167 return ( a_fVal1 > a_fVal2 ) ? a_fVal1 : a_fVal2;
180 static qreal
sqr ( qreal v1 )
190 static qreal
add ( qreal v1, qreal v2 )
195 static qreal
land ( qreal v1, qreal v2 )
197 return static_cast<int>( v1 ) &
static_cast<int>( v2 );
200 static qreal
FirstArg (
const qreal* a_afArg,
int a_iArgc )
204 throw QmuParserError (
"too few arguments for function FirstArg." );
210 static qreal
LastArg (
const qreal* a_afArg,
int a_iArgc )
214 throw QmuParserError (
"too few arguments for function LastArg." );
217 return a_afArg[a_iArgc - 1];
220 static qreal
Sum (
const qreal* a_afArg,
int a_iArgc )
228 for (
int i = 0; i < a_iArgc; ++i )
235 static qreal
Rnd ( qreal v )
237 return static_cast<qreal
>( ( 1 + ( v * QRandomGenerator::global()->generate() / ( RAND_MAX + 1.0 ) ) ) );
242 return static_cast<qreal
>( ( 1 + ( 1000.0f *
static_cast<qreal
>(QRandomGenerator::global()->generate()) / ( RAND_MAX + 1.0 ) ) ) );
257 int val = v1.toInt();
258 return static_cast<qreal
>(val);
261 static qreal
StrFun2 (
const QString & v1, qreal v2 )
263 int val = v1.toInt();
264 return static_cast<qreal
>( val + v2 );
267 static qreal
StrFun3 (
const QString & v1, qreal v2, qreal v3 )
269 int val = v1.toInt();
270 return val + v2 + v3;
275 qreal val = a_szMsg.toDouble();
280 static qreal
Mega ( qreal a_fVal )
282 return a_fVal *
static_cast<qreal
>( 1e6 );
287 return a_fVal *
static_cast<qreal
>( 1e-6 );
292 return a_fVal /
static_cast<qreal
>( 1e3 );
296 static int IsHexVal (
const QString &a_szExpr,
int *a_iPos, qreal *a_fVal,
const QLocale &locale,
297 const QChar &decimal,
const QChar &thousand);
Error class of the parser.
Test cases for unit testing.
static qreal ValueOf(const QString &)
static qreal land(qreal v1, qreal v2)
QmuParserTester(QObject *parent=nullptr)
static qreal f3of5(qreal, qreal, qreal v, qreal, qreal)
static qreal f2of2(qreal, qreal v)
int(QmuParserTester::* testfun_type)()
static qreal f2of3(qreal, qreal v, qreal)
static qreal StrToFloat(const QString &a_szMsg)
static qreal f1of2(qreal v, qreal)
static void Abort()
Internal error in test class Test is going to be aborted.
static qreal f4of4(qreal, qreal, qreal, qreal v)
static int EqnTest(const QString &a_str, double a_fRes, bool a_fPass)
Evaluate a tet expression.
static qreal f4of5(qreal, qreal, qreal, qreal v, qreal)
static qreal Mega(qreal a_fVal)
static int ThrowTest(const QString &a_str, int a_iErrc, bool a_bFail=true)
int TestNames()
Check muParser name restriction enforcement.
static qreal f1of4(qreal v, qreal, qreal, qreal)
static qreal f2of5(qreal, qreal v, qreal, qreal, qreal)
static qreal f3of4(qreal, qreal, qreal v, qreal)
static qreal add(qreal v1, qreal v2)
static qreal StrFun3(const QString &v1, qreal v2, qreal v3)
static qreal sign(qreal v)
static qreal Sum(const qreal *a_afArg, int a_iArgc)
static qreal f2of4(qreal, qreal v, qreal, qreal)
static qreal f1of1(qreal v)
static qreal StrFun1(const QString &v1)
static qreal RndWithString(const char_type *)
static int EqnTestWithVarChange(const QString &a_str, double a_fRes1, double a_fVar1, double a_fRes2, double a_fVar2)
Evaluate a tet expression.
static qreal f3of3(qreal, qreal, qreal v)
static qreal sqr(qreal v1)
static qreal f1of5(qreal v, qreal, qreal, qreal, qreal)
static qreal Min(qreal a_fVal1, qreal a_fVal2)
static qreal Rnd(qreal v)
static qreal Max(qreal a_fVal1, qreal a_fVal2)
void AddTest(testfun_type a_pFun)
static qreal f5of5(qreal, qreal, qreal, qreal, qreal v)
static qreal LastArg(const qreal *a_afArg, int a_iArgc)
static qreal f1of3(qreal v, qreal, qreal)
static qreal plus2(qreal v1)
QVector< testfun_type > m_vTestFun
static qreal Milli(qreal a_fVal)
static qreal FirstArg(const qreal *a_afArg, int a_iArgc)
static int IsHexVal(const QString &a_szExpr, int *a_iPos, qreal *a_fVal, const QLocale &locale, const QChar &decimal, const QChar &thousand)
static qreal StrFun2(const QString &v1, qreal v2)
static qreal times3(qreal v1)
static qreal Micro(qreal a_fVal)
static int EqnTestBulk(const QString &a_str, double a_fRes[4], bool a_fPass)
Test an expression in Bulk Mode.
Namespace for mathematical applications.
string_type::value_type char_type
The character type used by the parser.
Definition of the standard floating point parser.
This file contains standard definitions used by the parser.
This file defines the error class used by the parser.