Tests: Difference between revisions

Jump to navigation Jump to search
293 bytes added ,  27 January 2022
m
→‎Assert: added tolerance info
(→‎Writing tests: added known failures and best practices section)
m (→‎Assert: added tolerance info)
Line 101: Line 101:
</syntaxhighlight>
</syntaxhighlight>


These are actually a shorthand version of
These are actually a shorthand version of {{codeline|%!test assert (foo (bar))}}, and {{codeline|assert}} is simply an Octave function that throws an error when two arguments fail to compare. A tolerance can be added to {{codeline|assert}} to pass results that are numerically not exactly equal:
{{codeline|%!test assert (foo (bar))}}, and {{codeline|assert}} is simply
<syntaxhighlight lang="Octave">
an Octave function that throws an error when two arguments fail to compare.
%!assert (pi, 3.14159)          # test fails as "Abs err 2.6536e-06 exceeds tol 0 by 3e-06"
%!assert (pi, 3.14159, 1e-5)    # test passes
</syntaxhighlight>


=== Error / Warning ===
=== Error / Warning ===
156

edits

Navigation menu