Produce an error if the specified condition is not met.
assert
can be called in three different ways.
assert (cond)
assert (cond, errmsg)
assert (cond, errmsg, …)
assert (cond, msg_id, errmsg, …)
Called with a single argument cond, assert
produces an error if
cond is false (numeric zero).
Any additional arguments are passed to the error
function for
processing.
assert (observed, expected)
Produce an error if observed is not the same as expected.
Note that observed and expected can be scalars, vectors, matrices, strings, cell arrays, or structures.
assert (observed, expected, tol)
Produce an error if observed is not the same as expected but equality comparison for numeric data uses a tolerance tol.
If tol is positive then it is an absolute tolerance which will produce
an error if abs (observed - expected) > abs (tol)
.
If tol is negative then it is a relative tolerance which will produce
an error if abs (observed - expected) >
abs (tol * expected)
.
If expected is zero tol will always be interpreted as an absolute tolerance.
If tol is not scalar its dimensions must agree with those of observed and expected and tests are performed on an element-by-element basis.
See also: fail, test, error, isequal.
Package: octave