assert
Assertion
assert(cond)
assert(x1,x2)
assert(x1,x2,delta)
assert(cond, message)
assert(x1,x2, message)
assert(x1,x2,delta, message)
| Inputs |
cond |
A boolean value |
x1 |
A scalar numerical value |
x2 |
A scalar numerical value |
delta |
A scalar numerical value |
message |
A string to be printed when the assertion fails.
|
Description
assert(cond) prints out a message if the input evaluates to false .
Otherwise it does nothing.
assert(x1,x2) prints out a message if the numerical inputs are not equal
otherwise it does nothing.
assert(x1,x2,delta) prints out a message if the first two numerical inputs
differ by more than delta; otherwise it does nothing.
If the the last input is a string, it is the message that is printed when
the assertion fails.
Example
>>assert(1+eps==1)
Assertion failed in $MAIN
>>assert(1+eps/2==1)
>>assert(1,1+eps,eps/2)
Assertion failed in $MAIN
>>assert(1,1+eps,eps*2)
>>assert(1,1+eps,eps/2,'The inputs are not equal')
The inputs are not equal