Ocean
Ocean::Test::ValidationPrecision Class Reference

This class implements a helper class to validate the accuracy of tests. More...

Data Structures

class  ScopedIteration
 Creates a new scoped iteration. More...
 

Public Member Functions

 ValidationPrecision (const double threshold)
 Creates a new precision-based validation object with specified threshold. More...
 
 ValidationPrecision (const double threshold, RandomGenerator &randomGenerator)
 Creates a new validation object associated with a random generator, by default the verified has succeeded. More...
 
 ~ValidationPrecision ()
 Destructs this validation object. More...
 
void addIteration (const bool accurate)
 Explicitly adds a new iteration which is either accurate or not. More...
 
void addIterations (const size_t accurateIterations, const size_t iterations)
 Explicitly adds new iterations for which the amount of accurate iterations is known. More...
 
void setFailed ()
 Explicitly sets the validation to be failed. More...
 
void setFailed (const char *file, const int line)
 Explicitly sets the validation to be failed. More...
 
uint64_t iterations () const
 Returns the number of iterations in which the precision has been determined. More...
 
uint64_t necessaryIterations () const
 Returns the necessary iterations to allow determining success or failure based on the specified success threshold. More...
 
bool needMoreIterations () const
 Returns whether the number of iterations is not yet sufficient to determine a success or failure. More...
 
bool succeeded () const
 Returns if this validation has succeeded. More...
 
double accuracy () const
 Returns the accuracy of all iterations. More...
 
double threshold () const
 Returns the defined threshold. More...
 
bool hasSetFailed () const
 Returns whether this validation object has been set to failed explicitly. More...
 
std::string randomGeneratorOutput () const
 Returns a string containing the random generator's initial seed, if any. More...
 

Protected Member Functions

 ValidationPrecision (const ValidationPrecision &)=delete
 Disabled copy constructor. More...
 
void setSucceededFalse ()
 Sets the succeeded state to false. More...
 

Protected Attributes

double threshold_ = 1.0
 The necessary percent of accurate iterations necessary for a successful verification, with range (0, 1]. More...
 
bool succeeded_ = true
 True, if the validation has succeeded; False, if the validation has failed. More...
 
uint64_t necessaryIterations_ = 0ull
 The number of iterations needed to determine success or failure. More...
 
uint64_t iterations_ = 0ull
 The overall number of iterations which have been added. More...
 
uint64_t accurateIterations_ = 0ull
 The number of iterations which were precise enough, with range [0, iterations_]. More...
 
RandomGeneratorrandomGenerator_ = nullptr
 Optional random generator object which will be used during validation. More...
 
bool succeededChecked_ = false
 True, if the success state of this validation has been checked. More...
 

Detailed Description

This class implements a helper class to validate the accuracy of tests.

See also
Validation.

Constructor & Destructor Documentation

◆ ValidationPrecision() [1/3]

Ocean::Test::ValidationPrecision::ValidationPrecision ( const double  threshold)
inlineexplicit

Creates a new precision-based validation object with specified threshold.

Parameters
thresholdThe necessary percent of accurate iterations necessary for a successful verification, with range (0, 1]

◆ ValidationPrecision() [2/3]

Ocean::Test::ValidationPrecision::ValidationPrecision ( const double  threshold,
RandomGenerator randomGenerator 
)
inline

Creates a new validation object associated with a random generator, by default the verified has succeeded.

Parameters
thresholdThe necessary percent of accurate iterations necessary for a successful verification, with range (0, 1]
randomGeneratorThe random generator which will be used during verification

◆ ~ValidationPrecision()

Ocean::Test::ValidationPrecision::~ValidationPrecision ( )
inline

Destructs this validation object.

◆ ValidationPrecision() [3/3]

Ocean::Test::ValidationPrecision::ValidationPrecision ( const ValidationPrecision )
protecteddelete

Disabled copy constructor.

Member Function Documentation

◆ accuracy()

double Ocean::Test::ValidationPrecision::accuracy ( ) const
inline

Returns the accuracy of all iterations.

Beware: Ensure that at least one iteration has been added.

Returns
The validation's accuracy, in percent, with range [0, 1]

◆ addIteration()

void Ocean::Test::ValidationPrecision::addIteration ( const bool  accurate)
inline

Explicitly adds a new iteration which is either accurate or not.

Parameters
accurateTrue, if the iteration was precise enough; False, if the iteration was not precise enough
See also
ScopedIteration.

◆ addIterations()

void Ocean::Test::ValidationPrecision::addIterations ( const size_t  accurateIterations,
const size_t  iterations 
)
inline

Explicitly adds new iterations for which the amount of accurate iterations is known.

Parameters
accurateIterationsThe number of accurate iterations, with range [0, iterations]
iterationsThe number of new iterations, with range [1, infinity)
See also
ScopedIteration.

◆ hasSetFailed()

bool Ocean::Test::ValidationPrecision::hasSetFailed ( ) const
inline

Returns whether this validation object has been set to failed explicitly.

This function is intended for internal use only, use succeeded() instead.

Returns
True, if so
See also
succeeded().

◆ iterations()

uint64_t Ocean::Test::ValidationPrecision::iterations ( ) const
inline

Returns the number of iterations in which the precision has been determined.

Returns
The number of iterations, with range [0, infinity)

◆ necessaryIterations()

uint64_t Ocean::Test::ValidationPrecision::necessaryIterations ( ) const
inline

Returns the necessary iterations to allow determining success or failure based on the specified success threshold.

Returns
The number of necessary iterations, with range [1, infinity)

◆ needMoreIterations()

bool Ocean::Test::ValidationPrecision::needMoreIterations ( ) const
inline

Returns whether the number of iterations is not yet sufficient to determine a success or failure.

Returns
True, if more iterations are required

◆ randomGeneratorOutput()

std::string Ocean::Test::ValidationPrecision::randomGeneratorOutput ( ) const
inline

Returns a string containing the random generator's initial seed, if any.

Returns
The string with initial seed test, empty if no random generator is associated with this validation object

◆ setFailed() [1/2]

void Ocean::Test::ValidationPrecision::setFailed ( )
inline

Explicitly sets the validation to be failed.

Setting this validation to be failed will result in a failed validation even if all iteration were precise enough.

See also
succeeded().

◆ setFailed() [2/2]

void Ocean::Test::ValidationPrecision::setFailed ( const char *  file,
const int  line 
)
inline

Explicitly sets the validation to be failed.

Setting this validation to be failed will result in a failed validation even if all iteration were precise enough.

Parameters
fileThe source file in which the function call happens, e.g., FILE, must be valid
lineThe line in the source file in which the function call happens, e.g., LINE, must be valid
See also
succeeded().

◆ setSucceededFalse()

void Ocean::Test::ValidationPrecision::setSucceededFalse ( )
inlineprotected

Sets the succeeded state to false.

◆ succeeded()

bool Ocean::Test::ValidationPrecision::succeeded ( ) const
inline

Returns if this validation has succeeded.

Returns
True, if so; False, if the validation has failed

◆ threshold()

double Ocean::Test::ValidationPrecision::threshold ( ) const
inline

Returns the defined threshold.

Returns
The validation object's precision threshold, with range [0, 1]

Field Documentation

◆ accurateIterations_

uint64_t Ocean::Test::ValidationPrecision::accurateIterations_ = 0ull
protected

The number of iterations which were precise enough, with range [0, iterations_].

◆ iterations_

uint64_t Ocean::Test::ValidationPrecision::iterations_ = 0ull
protected

The overall number of iterations which have been added.

◆ necessaryIterations_

uint64_t Ocean::Test::ValidationPrecision::necessaryIterations_ = 0ull
protected

The number of iterations needed to determine success or failure.

◆ randomGenerator_

RandomGenerator* Ocean::Test::ValidationPrecision::randomGenerator_ = nullptr
protected

Optional random generator object which will be used during validation.

◆ succeeded_

bool Ocean::Test::ValidationPrecision::succeeded_ = true
protected

True, if the validation has succeeded; False, if the validation has failed.

◆ succeededChecked_

bool Ocean::Test::ValidationPrecision::succeededChecked_ = false
mutableprotected

True, if the success state of this validation has been checked.

◆ threshold_

double Ocean::Test::ValidationPrecision::threshold_ = 1.0
protected

The necessary percent of accurate iterations necessary for a successful verification, with range (0, 1].


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