Theoretica
A C++ numerical and automatic mathematical library
chebyshev::err Namespace Reference

Error checking module. More...

Classes

class  assert_result
 Result of assertion checking of a function. More...
 
class  errno_result
 Result of errno checking of a function. More...
 
class  exception_result
 Result of exception checking of a function. More...
 
class  err_settings
 Global settings of the error testing module. More...
 
class  err_results
 error checking More...
 

Functions

void setup (const std::string &moduleName, int argc=0, const char **argv=nullptr)
 Setup error checking module. More...
 
void terminate (bool exit=true)
 Terminate the error testing environment. More...
 
void assert (const std::string &name, bool exp, std::string description="", bool quiet=false)
 Assert that an expression is true. More...
 
template<typename Function , typename InputType >
void check_errno (const std::string &name, Function f, InputType x, int expected_errno, bool quiet=false)
 Check errno value after function call. More...
 
template<typename Function , typename InputType >
void check_errno (const std::string &name, Function f, std::function< InputType()> generator, int expected_errno, bool quiet=false)
 Check errno value after function call. More...
 
template<typename Function , typename InputType >
void check_errno (const std::string &name, Function f, InputType x, std::vector< int > &expected_flags, bool quiet=false)
 Check errno value after function call. More...
 
template<typename Function , typename InputType >
void check_errno (const std::string &name, Function f, std::function< InputType()> generator, std::vector< int > &expected_flags, bool quiet=false)
 Check errno value after function call. More...
 
template<typename Function , typename InputType >
void check_exception (const std::string &name, Function f, InputType x, bool quiet=false)
 Check that an exception is thrown during a function call. More...
 
template<typename Function , typename InputType >
void check_exception (const std::string &name, Function f, std::function< InputType()> generator, bool quiet=false)
 Check that an exception is thrown during a function call. More...
 
template<typename ExceptionType , typename Function , typename InputType >
void check_exception (const std::string &name, Function f, InputType x, bool quiet=false)
 Check that an exception is thrown during a function call and that the type of the exception is correct. More...
 
template<typename ExceptionType , typename Function , typename InputType >
void check_exception (const std::string &name, Function f, std::function< InputType()> generator, bool quiet=false)
 Check that an exception is thrown during a function call and that the type of the exception is correct. More...
 

Variables

struct chebyshev::err::err_settings settings
 
struct chebyshev::err::err_results results
 

Detailed Description

Error checking module.

This module provides functions to test error reporting with different methods. Assertions are checked with err::assert, while the value of errno after a function call can be checked using err::check_errno and the throwing of exceptions can be checked using check_exception.

Function Documentation

◆ assert()

void chebyshev::err::assert ( const std::string &  name,
bool  exp,
std::string  description = "",
bool  quiet = false 
)
inline

Assert that an expression is true.

Parameters
nameName of the check (function name or test case name).
expExpression to test for truth.
descriptionDescription of the assertion.

◆ check_errno() [1/4]

template<typename Function , typename InputType >
void chebyshev::err::check_errno ( const std::string &  name,
Function  f,
InputType  x,
int  expected_errno,
bool  quiet = false 
)
inline

Check errno value after function call.

Parameters
nameThe name of the function or test case
fThe function to test
xThe input value to evaluate the function at
expected_errnoThe expected value of errno

◆ check_errno() [2/4]

template<typename Function , typename InputType >
void chebyshev::err::check_errno ( const std::string &  name,
Function  f,
InputType  x,
std::vector< int > &  expected_flags,
bool  quiet = false 
)
inline

Check errno value after function call.

Parameters
nameThe name of the function or test case
fThe function to test
xThe input value to evaluate the function at
expected_flagsA list of the expected errno flags

◆ check_errno() [3/4]

template<typename Function , typename InputType >
void chebyshev::err::check_errno ( const std::string &  name,
Function  f,
std::function< InputType()>  generator,
int  expected_errno,
bool  quiet = false 
)
inline

Check errno value after function call.

Parameters
nameThe name of the function or test case
fThe function to test
generatorA function which takes in an index and returns a (potentially random) input value
expected_errnoThe expected value of errno

◆ check_errno() [4/4]

template<typename Function , typename InputType >
void chebyshev::err::check_errno ( const std::string &  name,
Function  f,
std::function< InputType()>  generator,
std::vector< int > &  expected_flags,
bool  quiet = false 
)

Check errno value after function call.

Parameters
nameThe name of the function or test case
fThe function to test
generatorA function which takes in an index and returns a (potentially random) input value
expected_flagsA list of the expected errno flags

◆ check_exception() [1/4]

template<typename Function , typename InputType >
void chebyshev::err::check_exception ( const std::string &  name,
Function  f,
InputType  x,
bool  quiet = false 
)
inline

Check that an exception is thrown during a function call.

Parameters
nameThe name of the function or test case
fThe function to test
xThe input value to use

◆ check_exception() [2/4]

template<typename ExceptionType , typename Function , typename InputType >
void chebyshev::err::check_exception ( const std::string &  name,
Function  f,
InputType  x,
bool  quiet = false 
)
inline

Check that an exception is thrown during a function call and that the type of the exception is correct.

Parameters
nameThe name of the function or test case
fThe function to test
xThe input value to use

◆ check_exception() [3/4]

template<typename Function , typename InputType >
void chebyshev::err::check_exception ( const std::string &  name,
Function  f,
std::function< InputType()>  generator,
bool  quiet = false 
)
inline

Check that an exception is thrown during a function call.

Parameters
nameThe name of the function or test case
fThe function to test
generatorA function which takes in an index and returns a (potentially random) input value

◆ check_exception() [4/4]

template<typename ExceptionType , typename Function , typename InputType >
void chebyshev::err::check_exception ( const std::string &  name,
Function  f,
std::function< InputType()>  generator,
bool  quiet = false 
)
inline

Check that an exception is thrown during a function call and that the type of the exception is correct.

Parameters
nameThe name of the function or test case
fThe function to test
generatorA function which takes in an index and returns a (potentially random) input value

◆ setup()

void chebyshev::err::setup ( const std::string &  moduleName,
int  argc = 0,
const char **  argv = nullptr 
)
inline

Setup error checking module.

Parameters
moduleNameName of the module under test.
argcThe number of command line arguments
argvA list of C-style strings containing the command line arguments.

◆ terminate()

void chebyshev::err::terminate ( bool  exit = true)
inline

Terminate the error testing environment.

If test cases have been run, their results will be printed.

Parameters
exitWhether to exit after terminating the module.