diff --git a/test/octfiles/test_all.m b/test/octfiles/test_all.m new file mode 100644 index 0000000..a6b28d3 --- /dev/null +++ b/test/octfiles/test_all.m @@ -0,0 +1,35 @@ +%% -*- texinfo -*- +%% @defun test_all () +%% tests +%% +%% @example +%% 42 +%% @result{} ans = 42 +%% @end example +%% +%% Note its not possible to call doctest from a doctest [1]. +%% Instead, we use octave BIST mechanism. +%% +%% [1] https://github.com/catch22/octave-doctest/issues/184 +%% +%% @end defun + +function test_all() + +end + +%!test +%! [numpass, numtests, ~] = doctest ('test_octfile_single_fcn'); +%! assert (numtests, 2) +%! assert (numpass, 2) + +%!test +%! % different behaviour with or without extension +%! [dir, ~, ~] = fileparts (which ('test_octfile_multi.oct')); +%! autoload ('test_subfcn1', fullfile (dir, 'test_octfile_multi.oct')); +%! [numpass, numtests, ~] = doctest ('test_octfile_multi'); +%! assert (numtests, 1) +%! assert (numpass, 1) +%! [numpass, numtests, ~] = doctest ('test_octfile_multi.oct'); +%! assert (numtests, 4) +%! assert (numpass, 4) diff --git a/test/octfiles/test_octfile_multi.cc b/test/octfiles/test_octfile_multi.cc new file mode 100644 index 0000000..f45e8ba --- /dev/null +++ b/test/octfiles/test_octfile_multi.cc @@ -0,0 +1,45 @@ +#include + +DEFUN_DLD (test_octfile_multi, args, , + "-*- texinfo -*-\n\ +@deftypefn {} {} test_octfile_multi ()\n\ +Testing\n\ +\n\ +@example\n\ +a = 42\n\ +@result{} a = 42\n\ +@end example\n\ +@end deftypefn") +{ + return ovl (0); +} + +DEFUN_DLD (test_subfcn1, args, , + "-*- texinfo -*-\n\ +@deftypefn {} {} test_subfcn1 ()\n\ +Testing\n\ +\n\ +@example\n\ +a = 43\n\ +@result{} a = 43\n\ +@end example\n\ +@end deftypefn") +{ + return ovl (0); +} + +DEFUN_DLD (test_subfcn2, args, , + "-*- texinfo -*-\n\ +@deftypefn {} {} test_subfcn2 ()\n\ +Testing\n\ +\n\ +@example\n\ +a = 44\n\ +@result{} a = 44\n\ +a = a + 1\n\ +@result{} a = 45\n\ +@end example\n\ +@end deftypefn") +{ + return ovl (0); +} diff --git a/test/octfiles/test_octfile_single_fcn.cc b/test/octfiles/test_octfile_single_fcn.cc new file mode 100644 index 0000000..0a066ea --- /dev/null +++ b/test/octfiles/test_octfile_single_fcn.cc @@ -0,0 +1,17 @@ +#include + +DEFUN_DLD (test_octfile_single_fcn, args, , + "-*- texinfo -*-\n\ +@deftypefn {} {} test_octfile_single_fcn ()\n\ +Testing\n\ +\n\ +@example\n\ +b = 42\n\ +@result{} b = 42\n\ +b = b + 1\n\ +@result{} b = 43\n\ +@end example\n\ +@end deftypefn") +{ + return ovl (0); +}