Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: add cc files for testing oct files #275

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions test/octfiles/test_all.m
Original file line number Diff line number Diff line change
@@ -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)
45 changes: 45 additions & 0 deletions test/octfiles/test_octfile_multi.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <octave/oct.h>

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);
}
17 changes: 17 additions & 0 deletions test/octfiles/test_octfile_single_fcn.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <octave/oct.h>

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);
}