NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
mu::Test::ParserTester Class Reference

Test cases for unit testing. More...

#include <muParserTest.h>

Collaboration diagram for mu::Test::ParserTester:

Public Types

typedef int(ParserTester::* testfun_type) ()
 

Public Member Functions

 ParserTester ()
 
void Run ()
 

Private Member Functions

int TestNames ()
 Check muParser name restriction enforcement. More...
 
int TestSyntax ()
 
int TestMultiArg ()
 
int TestPostFix ()
 
int TestExpression ()
 
int TestInfixOprt ()
 
int TestBinOprt ()
 
int TestVarConst ()
 
int TestInterface ()
 
int TestException ()
 
int TestStrArg ()
 
int TestIfThenElse ()
 
void Abort () const
 Internal error in test class Test is going to be aborted. More...
 
void AddTest (testfun_type a_pFun)
 
int EqnTest (const string_type &a_str, double a_fRes, bool a_fPass)
 Evaluate a tet expression. More...
 
int EqnTestWithVarChange (const string_type &a_str, double a_fRes1, double a_fVar1, double a_fRes2, double a_fVar2)
 Evaluate a tet expression. More...
 
int ThrowTest (const string_type &a_str, int a_iErrc, bool a_bFail=true)
 
int EqnTestInt (const string_type &a_str, double a_fRes, bool a_fPass)
 

Static Private Member Functions

static value_type f1of1 (value_type v)
 
static value_type f1of2 (value_type v, value_type)
 
static value_type f2of2 (value_type, value_type v)
 
static value_type f1of3 (value_type v, value_type, value_type)
 
static value_type f2of3 (value_type, value_type v, value_type)
 
static value_type f3of3 (value_type, value_type, value_type v)
 
static value_type f1of4 (value_type v, value_type, value_type, value_type)
 
static value_type f2of4 (value_type, value_type v, value_type, value_type)
 
static value_type f3of4 (value_type, value_type, value_type v, value_type)
 
static value_type f4of4 (value_type, value_type, value_type, value_type v)
 
static value_type f1of5 (value_type v, value_type, value_type, value_type, value_type)
 
static value_type f2of5 (value_type, value_type v, value_type, value_type, value_type)
 
static value_type f3of5 (value_type, value_type, value_type v, value_type, value_type)
 
static value_type f4of5 (value_type, value_type, value_type, value_type v, value_type)
 
static value_type f5of5 (value_type, value_type, value_type, value_type, value_type v)
 
static value_type Min (value_type a_fVal1, value_type a_fVal2)
 
static value_type Max (value_type a_fVal1, value_type a_fVal2)
 
static value_type plus2 (value_type v1)
 
static value_type times3 (value_type v1)
 
static value_type sqr (value_type v1)
 
static value_type sign (value_type v)
 
static value_type add (value_type v1, value_type v2)
 
static value_type land (value_type v1, value_type v2)
 
static value_type FirstArg (const value_type *a_afArg, int a_iArgc)
 
static value_type LastArg (const value_type *a_afArg, int a_iArgc)
 
static value_type Sum (const value_type *a_afArg, int a_iArgc)
 
static value_type Rnd (value_type v)
 
static value_type RndWithString (const char_type *)
 
static value_type Ping ()
 
static value_type ValueOf (const char_type *)
 
static value_type StrFun1 (const char_type *v1)
 
static value_type StrFun2 (const char_type *v1, value_type v2)
 
static value_type StrFun3 (const char_type *v1, value_type v2, value_type v3)
 
static value_type StrToFloat (const char_type *a_szMsg)
 
static value_type Mega (value_type a_fVal)
 
static value_type Micro (value_type a_fVal)
 
static value_type Milli (value_type a_fVal)
 
static int IsHexVal (const char_type *a_szExpr, int *a_iPos, value_type *a_fVal)
 

Private Attributes

std::vector< testfun_typem_vTestFun
 

Static Private Attributes

static int c_iCount = 0
 

Detailed Description

Test cases for unit testing.

(C) 2004-2011 Ingo Berg

Definition at line 49 of file muParserTest.h.

Member Typedef Documentation

◆ testfun_type

typedef int(ParserTester::* mu::Test::ParserTester::testfun_type) ()

Definition at line 184 of file muParserTest.h.

Constructor & Destructor Documentation

◆ ParserTester()

mu::Test::ParserTester::ParserTester ( )

Definition at line 49 of file muParserTest.cpp.

References AddTest(), c_iCount, TestBinOprt(), TestException(), TestExpression(), TestIfThenElse(), TestInfixOprt(), TestInterface(), TestMultiArg(), TestNames(), TestPostFix(), TestStrArg(), TestSyntax(), and TestVarConst().

Here is the call graph for this function:

Member Function Documentation

◆ Abort()

void mu::Test::ParserTester::Abort ( ) const
private

Internal error in test class Test is going to be aborted.

Definition at line 1441 of file muParserTest.cpp.

References _nrT, and mu::console().

Referenced by Run().

Here is the call graph for this function:

◆ add()

static value_type mu::Test::ParserTester::add ( value_type  v1,
value_type  v2 
)
inlinestaticprivate

Definition at line 82 of file muParserTest.h.

Referenced by EqnTest().

◆ AddTest()

void mu::Test::ParserTester::AddTest ( testfun_type  a_pFun)
private

Definition at line 1057 of file muParserTest.cpp.

References m_vTestFun.

Referenced by ParserTester().

◆ EqnTest()

int mu::Test::ParserTester::EqnTest ( const string_type a_str,
double  a_fRes,
bool  a_fPass 
)
private

◆ EqnTestInt()

int mu::Test::ParserTester::EqnTestInt ( const string_type a_str,
double  a_fRes,
bool  a_fPass 
)
private

Definition at line 1389 of file muParserTest.cpp.

References _nrT, c_iCount, mu::console(), mu::ParserBase::DefineConst(), mu::ParserBase::DefineVar(), mu::ParserBase::Eval(), mu::ParserError::GetExpr(), mu::ParserError::GetMsg(), and mu::ParserBase::SetExpr().

Referenced by TestBinOprt().

Here is the call graph for this function:

◆ EqnTestWithVarChange()

int mu::Test::ParserTester::EqnTestWithVarChange ( const string_type a_str,
double  a_fVar1,
double  a_fRes1,
double  a_fVar2,
double  a_fRes2 
)
private

Evaluate a tet expression.

Returns
1 in case of a failure, 0 otherwise.

Definition at line 1157 of file muParserTest.cpp.

References _nrT, c_iCount, mu::console(), mu::ParserBase::DefineVar(), mu::ParserBase::Eval(), mu::ParserError::GetMsg(), and mu::ParserBase::SetExpr().

Referenced by TestVarConst().

Here is the call graph for this function:

◆ f1of1()

static value_type mu::Test::ParserTester::f1of1 ( value_type  v)
inlinestaticprivate

Definition at line 55 of file muParserTest.h.

Referenced by EqnTest(), and TestNames().

◆ f1of2()

static value_type mu::Test::ParserTester::f1of2 ( value_type  v,
value_type   
)
inlinestaticprivate

Definition at line 57 of file muParserTest.h.

Referenced by EqnTest(), and TestNames().

◆ f1of3()

static value_type mu::Test::ParserTester::f1of3 ( value_type  v,
value_type  ,
value_type   
)
inlinestaticprivate

Definition at line 60 of file muParserTest.h.

Referenced by EqnTest().

◆ f1of4()

static value_type mu::Test::ParserTester::f1of4 ( value_type  v,
value_type  ,
value_type  ,
value_type   
)
inlinestaticprivate

Definition at line 64 of file muParserTest.h.

Referenced by EqnTest().

◆ f1of5()

static value_type mu::Test::ParserTester::f1of5 ( value_type  v,
value_type  ,
value_type  ,
value_type  ,
value_type   
)
inlinestaticprivate

Definition at line 69 of file muParserTest.h.

Referenced by EqnTest().

◆ f2of2()

static value_type mu::Test::ParserTester::f2of2 ( value_type  ,
value_type  v 
)
inlinestaticprivate

Definition at line 58 of file muParserTest.h.

Referenced by EqnTest().

◆ f2of3()

static value_type mu::Test::ParserTester::f2of3 ( value_type  ,
value_type  v,
value_type   
)
inlinestaticprivate

Definition at line 61 of file muParserTest.h.

Referenced by EqnTest().

◆ f2of4()

static value_type mu::Test::ParserTester::f2of4 ( value_type  ,
value_type  v,
value_type  ,
value_type   
)
inlinestaticprivate

Definition at line 65 of file muParserTest.h.

Referenced by EqnTest().

◆ f2of5()

static value_type mu::Test::ParserTester::f2of5 ( value_type  ,
value_type  v,
value_type  ,
value_type  ,
value_type   
)
inlinestaticprivate

Definition at line 70 of file muParserTest.h.

Referenced by EqnTest().

◆ f3of3()

static value_type mu::Test::ParserTester::f3of3 ( value_type  ,
value_type  ,
value_type  v 
)
inlinestaticprivate

Definition at line 62 of file muParserTest.h.

Referenced by EqnTest().

◆ f3of4()

static value_type mu::Test::ParserTester::f3of4 ( value_type  ,
value_type  ,
value_type  v,
value_type   
)
inlinestaticprivate

Definition at line 66 of file muParserTest.h.

Referenced by EqnTest().

◆ f3of5()

static value_type mu::Test::ParserTester::f3of5 ( value_type  ,
value_type  ,
value_type  v,
value_type  ,
value_type   
)
inlinestaticprivate

Definition at line 71 of file muParserTest.h.

Referenced by EqnTest().

◆ f4of4()

static value_type mu::Test::ParserTester::f4of4 ( value_type  ,
value_type  ,
value_type  ,
value_type  v 
)
inlinestaticprivate

Definition at line 67 of file muParserTest.h.

Referenced by EqnTest().

◆ f4of5()

static value_type mu::Test::ParserTester::f4of5 ( value_type  ,
value_type  ,
value_type  ,
value_type  v,
value_type   
)
inlinestaticprivate

Definition at line 72 of file muParserTest.h.

Referenced by EqnTest().

◆ f5of5()

static value_type mu::Test::ParserTester::f5of5 ( value_type  ,
value_type  ,
value_type  ,
value_type  ,
value_type  v 
)
inlinestaticprivate

Definition at line 73 of file muParserTest.h.

Referenced by EqnTest().

◆ FirstArg()

static value_type mu::Test::ParserTester::FirstArg ( const value_type a_afArg,
int  a_iArgc 
)
inlinestaticprivate

Definition at line 86 of file muParserTest.h.

References _nrT.

Referenced by EqnTest().

◆ IsHexVal()

int mu::Test::ParserTester::IsHexVal ( const char_type a_szExpr,
int *  a_iPos,
value_type a_fVal 
)
staticprivate

Definition at line 69 of file muParserTest.cpp.

References fast_float::hex.

Referenced by EqnTest().

◆ land()

static value_type mu::Test::ParserTester::land ( value_type  v1,
value_type  v2 
)
inlinestaticprivate

Definition at line 83 of file muParserTest.h.

Referenced by EqnTest().

◆ LastArg()

static value_type mu::Test::ParserTester::LastArg ( const value_type a_afArg,
int  a_iArgc 
)
inlinestaticprivate

Definition at line 94 of file muParserTest.h.

References _nrT.

Referenced by EqnTest().

◆ Max()

static value_type mu::Test::ParserTester::Max ( value_type  a_fVal1,
value_type  a_fVal2 
)
inlinestaticprivate

Definition at line 76 of file muParserTest.h.

Referenced by EqnTest().

◆ Mega()

static value_type mu::Test::ParserTester::Mega ( value_type  a_fVal)
inlinestaticprivate

Definition at line 161 of file muParserTest.h.

Referenced by EqnTest().

◆ Micro()

static value_type mu::Test::ParserTester::Micro ( value_type  a_fVal)
inlinestaticprivate

Definition at line 162 of file muParserTest.h.

◆ Milli()

static value_type mu::Test::ParserTester::Milli ( value_type  a_fVal)
inlinestaticprivate

Definition at line 163 of file muParserTest.h.

Referenced by EqnTest(), and ThrowTest().

◆ Min()

static value_type mu::Test::ParserTester::Min ( value_type  a_fVal1,
value_type  a_fVal2 
)
inlinestaticprivate

Definition at line 75 of file muParserTest.h.

Referenced by EqnTest().

◆ Ping()

static value_type mu::Test::ParserTester::Ping ( )
inlinestaticprivate

Definition at line 122 of file muParserTest.h.

Referenced by EqnTest(), and ThrowTest().

◆ plus2()

static value_type mu::Test::ParserTester::plus2 ( value_type  v1)
inlinestaticprivate

Definition at line 78 of file muParserTest.h.

Referenced by EqnTest().

◆ Rnd()

static value_type mu::Test::ParserTester::Rnd ( value_type  v)
inlinestaticprivate

Definition at line 112 of file muParserTest.h.

◆ RndWithString()

static value_type mu::Test::ParserTester::RndWithString ( const char_type )
inlinestaticprivate

Definition at line 117 of file muParserTest.h.

◆ Run()

void mu::Test::ParserTester::Run ( )

Definition at line 1063 of file muParserTest.cpp.

References Abort(), c_iCount, mu::console(), mu::ParserError::GetMsg(), mu::ParserError::GetToken(), and m_vTestFun.

Here is the call graph for this function:

◆ sign()

static value_type mu::Test::ParserTester::sign ( value_type  v)
inlinestaticprivate

Definition at line 81 of file muParserTest.h.

Referenced by EqnTest().

◆ sqr()

static value_type mu::Test::ParserTester::sqr ( value_type  v1)
inlinestaticprivate

Definition at line 80 of file muParserTest.h.

Referenced by EqnTest().

◆ StrFun1()

static value_type mu::Test::ParserTester::StrFun1 ( const char_type v1)
inlinestaticprivate

Definition at line 132 of file muParserTest.h.

Referenced by EqnTest(), and ThrowTest().

◆ StrFun2()

static value_type mu::Test::ParserTester::StrFun2 ( const char_type v1,
value_type  v2 
)
inlinestaticprivate

Definition at line 139 of file muParserTest.h.

Referenced by EqnTest(), and ThrowTest().

◆ StrFun3()

static value_type mu::Test::ParserTester::StrFun3 ( const char_type v1,
value_type  v2,
value_type  v3 
)
inlinestaticprivate

Definition at line 146 of file muParserTest.h.

Referenced by EqnTest(), and ThrowTest().

◆ StrToFloat()

static value_type mu::Test::ParserTester::StrToFloat ( const char_type a_szMsg)
inlinestaticprivate

Definition at line 153 of file muParserTest.h.

Referenced by EqnTest().

◆ Sum()

static value_type mu::Test::ParserTester::Sum ( const value_type a_afArg,
int  a_iArgc 
)
inlinestaticprivate

Definition at line 102 of file muParserTest.h.

References _nrT.

Referenced by EqnTest().

◆ TestBinOprt()

int mu::Test::ParserTester::TestBinOprt ( )
private

Definition at line 160 of file muParserTest.cpp.

References _nrT, mu::console(), EqnTest(), and EqnTestInt().

Referenced by ParserTester().

Here is the call graph for this function:

◆ TestException()

int mu::Test::ParserTester::TestException ( )
private

◆ TestExpression()

int mu::Test::ParserTester::TestExpression ( )
private

Definition at line 788 of file muParserTest.cpp.

References _nrT, mu::console(), and EqnTest().

Referenced by ParserTester().

Here is the call graph for this function:

◆ TestIfThenElse()

int mu::Test::ParserTester::TestIfThenElse ( )
private

Definition at line 871 of file muParserTest.cpp.

References _nrT, mu::console(), mu::ecMISPLACED_COLON, mu::ecMISSING_ELSE_CLAUSE, mu::ecUNASSIGNABLE_TOKEN, mu::ecUNEXPECTED_CONDITIONAL, EqnTest(), and ThrowTest().

Referenced by ParserTester().

Here is the call graph for this function:

◆ TestInfixOprt()

int mu::Test::ParserTester::TestInfixOprt ( )
private

Definition at line 670 of file muParserTest.cpp.

References _nrT, mu::console(), EqnTest(), and PARSER_CONST_PI.

Referenced by ParserTester().

Here is the call graph for this function:

◆ TestInterface()

int mu::Test::ParserTester::TestInterface ( )
private

Definition at line 91 of file muParserTest.cpp.

References _nrT, mu::console(), mu::ParserBase::DefineVar(), mu::ParserBase::Eval(), mu::ParserBase::RemoveVar(), and mu::ParserBase::SetExpr().

Referenced by ParserTester().

Here is the call graph for this function:

◆ TestMultiArg()

int mu::Test::ParserTester::TestMultiArg ( )
private

Definition at line 573 of file muParserTest.cpp.

References _nrT, mu::console(), and EqnTest().

Referenced by ParserTester().

Here is the call graph for this function:

◆ TestNames()

int mu::Test::ParserTester::TestNames ( )
private

Check muParser name restriction enforcement.

Definition at line 302 of file muParserTest.cpp.

References _nrT, mu::ParserBase::ClearConst(), mu::ParserBase::ClearPostfixOprt(), mu::console(), mu::ParserBase::EnableBuiltInOprt(), f1of1(), f1of2(), and PARSER_THROWCHECK.

Referenced by ParserTester().

Here is the call graph for this function:

◆ TestPostFix()

int mu::Test::ParserTester::TestPostFix ( )
private

Definition at line 736 of file muParserTest.cpp.

References _nrT, mu::console(), mu::ecUNASSIGNABLE_TOKEN, mu::ecUNEXPECTED_EOF, mu::ecUNEXPECTED_PARENS, EqnTest(), and ThrowTest().

Referenced by ParserTester().

Here is the call graph for this function:

◆ TestStrArg()

int mu::Test::ParserTester::TestStrArg ( )
private

Definition at line 134 of file muParserTest.cpp.

References _nrT, mu::console(), and EqnTest().

Referenced by ParserTester().

Here is the call graph for this function:

◆ TestSyntax()

int mu::Test::ParserTester::TestSyntax ( )
private

Definition at line 411 of file muParserTest.cpp.

References _nrT, mu::console(), mu::ecUNEXPECTED_EOF, EqnTest(), and ThrowTest().

Referenced by ParserTester().

Here is the call graph for this function:

◆ TestVarConst()

int mu::Test::ParserTester::TestVarConst ( )
private

Definition at line 463 of file muParserTest.cpp.

References _nrT, mu::console(), mu::ParserBase::DefineVar(), EqnTest(), EqnTestWithVarChange(), mu::ParserBase::GetUsedVar(), mu::ParserBase::GetVar(), and mu::ParserBase::SetExpr().

Referenced by ParserTester().

Here is the call graph for this function:

◆ ThrowTest()

int mu::Test::ParserTester::ThrowTest ( const string_type a_str,
int  a_iErrc,
bool  a_bFail = true 
)
private

Definition at line 1104 of file muParserTest.cpp.

References _nrT, c_iCount, mu::console(), mu::ParserBase::DefineFun(), mu::ParserBase::DefinePostfixOprt(), mu::ParserBase::DefineVar(), mu::ParserBase::Eval(), mu::ParserError::GetCode(), mu::ParserError::GetMsg(), Milli(), Ping(), mu::ParserBase::SetExpr(), StrFun1(), StrFun2(), StrFun3(), and ValueOf().

Referenced by TestException(), TestIfThenElse(), TestPostFix(), and TestSyntax().

Here is the call graph for this function:

◆ times3()

static value_type mu::Test::ParserTester::times3 ( value_type  v1)
inlinestaticprivate

Definition at line 79 of file muParserTest.h.

Referenced by EqnTest().

◆ ValueOf()

static value_type mu::Test::ParserTester::ValueOf ( const char_type )
inlinestaticprivate

Definition at line 127 of file muParserTest.h.

Referenced by EqnTest(), and ThrowTest().

Member Data Documentation

◆ c_iCount

int mu::Test::ParserTester::c_iCount = 0
staticprivate

Definition at line 52 of file muParserTest.h.

Referenced by EqnTest(), EqnTestInt(), EqnTestWithVarChange(), ParserTester(), Run(), and ThrowTest().

◆ m_vTestFun

std::vector<testfun_type> mu::Test::ParserTester::m_vTestFun
private

Definition at line 190 of file muParserTest.h.

Referenced by AddTest(), and Run().


The documentation for this class was generated from the following files: