NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
Assertion Class Reference

This class handles assertions and throws the corresponding exception, if the assertion fails. It is currently used as global singleton, but is not restricted to this pattern. More...

#include <error.hpp>

Collaboration diagram for Assertion:

Public Member Functions

 Assertion ()
 
void reset ()
 Resets the assertion handler. More...
 
void resetStats ()
 Resets the internal statistic variables for accumulating the total number of executed and the number of failed tests. More...
 
void enable (const std::string &sExpr)
 Enables the assertion handler using the passed expression. More...
 
void checkAssertion (mu::value_type *v, int nNum)
 Checks the return value of a muParser evaluated result. More...
 
void checkAssertion (const Matrix &_mMatrix)
 Checks the return value of the matrix operation. More...
 
void checkAssertion (const StringResult &strRes)
 Checks the return vale of the string parser in the not-numerical-only case. More...
 
AssertionStats getStats () const
 Returns the current tests stats. More...
 

Private Member Functions

void assertionFail ()
 This member function is a wrapper around the assertion error. More...
 

Private Attributes

std::string sAssertedExpression
 
bool assertionMode
 
AssertionStats stats
 

Detailed Description

This class handles assertions and throws the corresponding exception, if the assertion fails. It is currently used as global singleton, but is not restricted to this pattern.

Definition at line 547 of file error.hpp.

Constructor & Destructor Documentation

◆ Assertion()

Assertion::Assertion ( )
inline

Definition at line 556 of file error.hpp.

Member Function Documentation

◆ assertionFail()

void Assertion::assertionFail ( )
private

This member function is a wrapper around the assertion error.

Returns
void

Definition at line 183 of file error.cpp.

References SyntaxError::ASSERTION_ERROR, AssertionStats::failed(), findCommand(), sAssertedExpression, and stats.

Referenced by checkAssertion().

Here is the call graph for this function:

◆ checkAssertion() [1/3]

void Assertion::checkAssertion ( const Matrix _mMatrix)

Checks the return value of the matrix operation.

Parameters
_mMatrixconst Matrix&
Returns
void

Definition at line 271 of file error.cpp.

References assertionFail(), assertionMode, Matrix::data(), stats, and AssertionStats::succeeded().

Here is the call graph for this function:

◆ checkAssertion() [2/3]

void Assertion::checkAssertion ( const StringResult strRes)

Checks the return vale of the string parser in the not-numerical-only case.

Parameters
strResconst StringResult&
Returns
void

Definition at line 298 of file error.cpp.

References assertionFail(), assertionMode, StringResult::bOnlyLogicals, NumeReKernel::getInstance(), NumeReKernel::getParser(), mu::ParserBase::SetExpr(), stats, AssertionStats::succeeded(), StringResult::vNoStringVal, and StringResult::vResult.

Here is the call graph for this function:

◆ checkAssertion() [3/3]

void Assertion::checkAssertion ( mu::value_type v,
int  nNum 
)

Checks the return value of a muParser evaluated result.

Parameters
vmu::value_type*
nNumint
Returns
void

Definition at line 244 of file error.cpp.

References assertionFail(), assertionMode, stats, and AssertionStats::succeeded().

Referenced by FlowCtrl::calc(), FlowCtrl::compile(), NumeRe::StringParser::evalAndFormat(), NumeReKernel::MainLoop(), performMatrixOperation(), and Procedure::ProcCalc().

Here is the call graph for this function:

◆ enable()

void Assertion::enable ( const std::string &  sExpr)

Enables the assertion handler using the passed expression.

Parameters
sExprconst std::string&
Returns
void

Definition at line 228 of file error.cpp.

References assertionMode, and sAssertedExpression.

Referenced by FlowCtrl::calc(), FlowCtrl::compile(), NumeReKernel::MainLoop(), and Procedure::ProcCalc().

◆ getStats()

AssertionStats Assertion::getStats ( ) const

Returns the current tests stats.

Returns
AssertionStats

Definition at line 328 of file error.cpp.

References stats.

Referenced by Procedure::execute(), and FlowCtrl::updateTestStats().

◆ reset()

void Assertion::reset ( )

Resets the assertion handler.

Returns
void

Definition at line 196 of file error.cpp.

References assertionMode, and sAssertedExpression.

Referenced by FlowCtrl::calc(), FlowCtrl::compile(), Procedure::execute(), and NumeReKernel::MainLoop().

◆ resetStats()

void Assertion::resetStats ( )

Resets the internal statistic variables for accumulating the total number of executed and the number of failed tests.

Returns
void

Definition at line 214 of file error.cpp.

References AssertionStats::reset(), and stats.

Referenced by NumeReKernel::MainLoop().

Here is the call graph for this function:

Member Data Documentation

◆ assertionMode

bool Assertion::assertionMode
private

Definition at line 551 of file error.hpp.

Referenced by checkAssertion(), enable(), and reset().

◆ sAssertedExpression

std::string Assertion::sAssertedExpression
private

Definition at line 550 of file error.hpp.

Referenced by assertionFail(), enable(), and reset().

◆ stats

AssertionStats Assertion::stats
private

Definition at line 553 of file error.hpp.

Referenced by assertionFail(), checkAssertion(), getStats(), and resetStats().


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