KSS Contract
C++ program by contract utilities
 All Namespaces Files Functions Macros
kss::contract Namespace Reference

Functions

void parameters (std::initializer_list< _private::Expression > exps)
 
void preconditions (std::initializer_list< _private::Expression > exps)
 
void conditions (std::initializer_list< _private::Expression > exps)
 
void postconditions (std::initializer_list< _private::Expression > exps)
 
std::string version () noexcept
 
std::string license () noexcept
 

Function Documentation

void kss::contract::conditions ( std::initializer_list< _private::Expression >  exps)
inline

Check that a condition is true. If an expression is not true, a message is written to std::cerr, and the program is terminated via std::terminate().

Typically you would not call this by creating the expression object manually. Instead you should create the expression object using the KSS_EXPR macro.

Example:

void myfn(int minValue, int maxValue) {
... your function code ...
KSS_EXPR(minValue > 0),
KSS_EXPR(minValue <= maxValue)
});
... your function code ...
}
Exceptions
std::invalid_argument(actually kss::contract::InvalidArgument) if one or more of the expressions fail.
anyexception that the expressions may throw

Definition at line 135 of file contract.hpp.

std::string kss::contract::license ( )
noexcept

Returns the text of the software license.

void kss::contract::parameters ( std::initializer_list< _private::Expression >  exps)
inline

The parameter check is a form of precondition that is presumed to be checking the incoming parameter arguments. One difference between this and the other conditions, is that instead of terminating execution, this throws an exception.

Typically you would not call this by creating the expression object manually. Instead you should create the expression object using the KSS_EXPR macro.

Example:

void myfn(int minValue, int maxValue) {
KSS_EXPR(minValue > 0),
KSS_EXPR(minValue <= maxValue)
});
... function code ...
}
Exceptions
std::invalid_argumentif one or more of the expressions fail
anyother exception that the expressions may throw

Definition at line 78 of file contract.hpp.

void kss::contract::postconditions ( std::initializer_list< _private::Expression >  exps)
inline

Check that a postcondition is true. If an expression is not true, a message is written to cerr, and the program is terminated via terminate().

Typically you would not call this by creating the expression object manually. Instead you should create the expression object using the KSS_EXPR macro.

Example:

void myfn(int minValue, int maxValue) {
... your function code ...
KSS_EXPR(minValue > 0),
KSS_EXPR(minValue <= maxValue)
});
}
Exceptions
anyexception that the expressions may throw

Definition at line 162 of file contract.hpp.

void kss::contract::preconditions ( std::initializer_list< _private::Expression >  exps)
inline

Check that a precondition is true. If an expression is not true, a message is written to std::cerr, and the program is terminated via std::terminate().

Typically you would not call this by creating the expression object manually. Instead you should create the expression object using the KSS_EXPR macro.

Example:

void myfn(int minValue, int maxValue) {
KSS_EXPR(minValue > 0),
KSS_EXPR(minValue <= maxValue)
});
... your function code ...
}
Exceptions
anyexception that the expressions may throw

Definition at line 105 of file contract.hpp.

std::string kss::contract::version ( )
noexcept

Returns a string of the form x.y.z<optional tags> that describes the version of this library.