Testing is a collection of procedures for unit testing icon code.
For example, to test a procedure that squares a number, you might run tests:
test_start ("Testing square procedure") test_approx_equals (4.0, square (2.0)) test_approx_equals (9.0, square (-3)) test_finish ()
For an output like:
Test: Testing square procedure Total: 2 Passed: 2 Failed: 0
ximage
test_approx_equals (expected, actual, message, eps)
Used to test if two numbers are within an agreed tolerance.
Parameters:
test_equals (expected, actual, message, comparator)
Used to test if two objects are equal.
Parameters:
test_fails (coexp, message)
Tests if the given coexp fails. i.e. if
@coexp => fails
Parameters:
test_finish ()
Finishes a suite of test results, and reports results.
test_start (title)
Initialises a new suite of test results. Must be called before running any tests.
Parameters:
test_succeeds (coexp, message)
Tests if the given coexp succeeds. i.e. if
@coexp => succeeds
Parameters: